Module: Trusty::Utilities::MethodNameExtensions

Included in:
Environment::ClassMethods
Defined in:
lib/trusty/utilities/method_name_extensions.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

dynamically add methods that forward to config



17
18
19
20
21
22
23
24
25
# File 'lib/trusty/utilities/method_name_extensions.rb', line 17

def method_missing(name, *args, &block)
  method_name = method_name_info(name)
  
  if method_name.define_for(self)
    method_name.value_for(self)
  else
    super
  end
end

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/trusty/utilities/method_name_extensions.rb', line 7

def self.included(base)
  base.extend self
end

Instance Method Details

#method_name_info(method_name) ⇒ Object



11
12
13
14
# File 'lib/trusty/utilities/method_name_extensions.rb', line 11

def method_name_info(method_name)
  @method_name_info ||= {}
  @method_name_info[method_name.to_s] ||= MethodName.new(method_name)
end