Module: Kawaii::MethodChain

Included in:
Route, RouteContext, RouteHandler
Defined in:
lib/kawaii/method_chain.rb

Overview

Allows handlers to use methods defined in outer contexts or at class scope. Set MethodChain.parent_scope in constructor.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(meth, *args)



7
8
9
# File 'lib/kawaii/method_chain.rb', line 7

def method_missing(meth, *args)
  @parent_scope.send(meth, *args) if @parent_scope.respond_to?(meth)
end

Instance Attribute Details

- (Object) parent_scope=(value) (writeonly)

Sets the attribute parent_scope

Parameters:

  • value

    the value to set the attribute parent_scope to.



5
6
7
# File 'lib/kawaii/method_chain.rb', line 5

def parent_scope=(value)
  @parent_scope = value
end

Instance Method Details

- (Boolean) respond_to?(method_name, include_private = false)

Returns:

  • (Boolean)


11
12
13
# File 'lib/kawaii/method_chain.rb', line 11

def respond_to?(method_name, include_private = false)
  super || @parent_scope.respond_to?(method_name, include_private)
end