Class: Seatbelt::Core::Iterators::MethodConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/seatbelt/core/iterators/method_config.rb

Overview

Public: Various methods useful for performing mathematical operations. All methods are module methods and should be called on the Math module.

Class Method Summary collapse

Class Method Details

.array_method_iterator(klass, gate_klass, scope) ⇒ Object

Public: Method config iterator block used by Gate#implement_class.

klass - The API class name gate_klass - The class that includes the Gate module

Returns a Proc that is useable for [].each



17
18
19
20
21
22
# File 'lib/seatbelt/core/iterators/method_config.rb', line 17

def self.array_method_iterator(klass, gate_klass, scope)
  return lambda do |method_config|
    method_config.send(:each_pair,
                       &hash_method_iterator(klass,gate_klass, scope))
  end
end

.hash_method_iterator(klass, gate_klass, scope) ⇒ Object

Public: Method config iterator block used by Gate#implement_class.

klass - The API class name gate_klass - The class that includes the Gate module

Returns a Proc that is useable for {}.each_pair



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/seatbelt/core/iterators/method_config.rb', line 31

def self.hash_method_iterator(klass, gate_klass, scope)
  methods_bucket = :implementation_methods if scope.eql?(:instance)
  methods_bucket = :implementation_class_methods if scope.eql?(:class)
  return lambda do |(key,value)|
    method_name = key
    implementation_config = {}
    implementation_config[method_name] = {
      :as => "#{klass}#{value[:as]}",
    }
    if value[:delegated]
      implementation_config[method_name][:delegated] = value[:delegated]
    end
    gate_klass.send(methods_bucket) << implementation_config
  end
end