Class: Takagi::Plugin::RoutePrefixProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/takagi/plugin.rb

Overview

Wraps the app to prefix routes registered by a plugin.

Constant Summary collapse

ROUTE_METHODS =
%i[get post put delete fetch observable observe].freeze

Instance Method Summary collapse

Constructor Details

#initialize(app, prefix) ⇒ RoutePrefixProxy

Returns a new instance of RoutePrefixProxy.



275
276
277
278
# File 'lib/takagi/plugin.rb', line 275

def initialize(app, prefix)
  @app = app
  @prefix = normalize_prefix(prefix)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kwargs, &block) ⇒ Object



287
288
289
290
291
292
293
# File 'lib/takagi/plugin.rb', line 287

def method_missing(name, *args, **kwargs, &block)
  if @app.respond_to?(name)
    @app.public_send(name, *args, **kwargs, &block)
  else
    super
  end
end

Instance Method Details

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


295
296
297
# File 'lib/takagi/plugin.rb', line 295

def respond_to_missing?(name, include_private = false)
  @app.respond_to?(name, include_private) || super
end