Class: AdequateExposure::Flow

Inherits:
Object
  • Object
show all
Defined in:
lib/adequate_exposure/flow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, options) ⇒ Flow

Public: Initialize a Flow. This object responds to missing methods errors and attempts to delegate them to other objects.

controller - The Controller class where the method was called. options - The options Hash of the Exposure instance being called. name - The String name of the Exposure instance.



11
12
13
14
15
# File 'lib/adequate_exposure/flow.rb', line 11

def initialize(controller, options)
  @controller = controller
  @options = options
  @name = options.fetch(:name)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Public: Attempts to re-delegate a method missing to the supplied block or the Behavior object.

name - The String name of the Exposure instance. *args - The arguments given for the missing method. block - The Proc invoked by the method.



23
24
25
26
27
28
29
# File 'lib/adequate_exposure/flow.rb', line 23

def method_missing(name, *args, &block)
  if respond_to_missing?(name)
    handle_flow_method(name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



3
4
5
# File 'lib/adequate_exposure/flow.rb', line 3

def controller
  @controller
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/adequate_exposure/flow.rb', line 3

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/adequate_exposure/flow.rb', line 3

def options
  @options
end

Instance Method Details

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

Public: Checks if the Behavior class can handle the missing method.

method_name - The name of method that has been called. include_private - Prevents this method from catching calls to private method (default: false).

Returns:

  • (Boolean)


36
37
38
# File 'lib/adequate_exposure/flow.rb', line 36

def respond_to_missing?(method_name, include_private = false)
  Behavior.method_defined?(method_name) || super
end