Module: MetaMethods

Extended by:
MetaMethods
Included in:
MetaMethods, WebmockMethod
Defined in:
lib/meta_methods/meta_methods.rb

Instance Method Summary collapse

Instance Method Details

#define_attribute(object, key, value) ⇒ Object



4
5
6
7
8
# File 'lib/meta_methods/meta_methods.rb', line 4

def define_attribute(object, key, value)
  object.singleton_class.send :attr_accessor, key.to_sym # creates accessor

  object.send "#{key}=".to_sym, value  # sets up value for attribute
end

#define_attributes(object, hash) ⇒ Object



10
11
12
13
14
# File 'lib/meta_methods/meta_methods.rb', line 10

def define_attributes(object, hash)
  hash.each_pair do |key, value|
    define_attribute(object, key, value)
  end
end