Class: Pavlov::OperationFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/pavlov/operation_finder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace) ⇒ OperationFinder

Returns a new instance of OperationFinder.



14
15
16
# File 'lib/pavlov/operation_finder.rb', line 14

def initialize(namespace)
  @namespace = namespace
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, attributes = {}) ⇒ Object



18
19
20
# File 'lib/pavlov/operation_finder.rb', line 18

def method_missing(name, attributes = {})
  find_klass(name)
end

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace.



5
6
7
# File 'lib/pavlov/operation_finder.rb', line 5

def namespace
  @namespace
end

Class Method Details

.find(namespace, operation_name) ⇒ Object



7
8
9
10
11
12
# File 'lib/pavlov/operation_finder.rb', line 7

def self.find(namespace, operation_name)
  operation_lookup_list = Inflector.camelize(operation_name.to_s).split('::')
  operation_lookup_list.reduce(namespace) do |current_namespace, namespace_or_operation_name|
    new(current_namespace).send(namespace_or_operation_name)
  end
end

Instance Method Details

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

Returns:

  • (Boolean)


22
23
24
# File 'lib/pavlov/operation_finder.rb', line 22

def respond_to_missing?(name, include_private = false)
  find_klass(name)
end