Class: Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/kongrations/environment.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/kongrations/environment.rb', line 4

def method_missing(*args)
  method = args.first
  return super unless respond_to_missing?(method.to_s)

  create_getter_and_setter(method[0..-2])
  value = args[1]
  send(method, value)
end

Instance Method Details

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

Returns:

  • (Boolean)


13
14
15
# File 'lib/kongrations/environment.rb', line 13

def respond_to_missing?(method_name, include_private = false)
  method_name.end_with?('=') || super
end