Class: Tomify::Constantly

Inherits:
Object
  • Object
show all
Defined in:
lib/tomify/constantly.rb

Instance Method Summary collapse

Constructor Details

#initialize(methods) ⇒ Constantly

Returns a new instance of Constantly.



3
4
5
6
7
8
9
10
# File 'lib/tomify/constantly.rb', line 3

def initialize(methods)
  methods.each do |key, value|
    define_singleton_method(key) { value.constantize }
    define_singleton_method("#{key}=") do |new_value|
      define_singleton_method(key) { new_value.constantize }
    end
  end
end