Module: Quandl::Support::Attributes::ClassMethods

Defined in:
lib/quandl/support/attributes.rb

Instance Method Summary collapse

Instance Method Details

#attributesObject



27
28
29
# File 'lib/quandl/support/attributes.rb', line 27

def attributes
  @attributes ||= []
end

#define_attribute(key) ⇒ Object (protected)



33
34
35
36
37
38
39
# File 'lib/quandl/support/attributes.rb', line 33

def define_attribute(key)
  key = key.to_s
  attributes << key unless attributes.include?(key)
  define_method( key ){ read_attribute(key) }
  define_method( "#{key}=" ){ |value| write_attribute(key, value) }
  define_method( "#{key}?" ){ !read_attribute(key).nil? }
end

#define_attributes(*attribute_names) ⇒ Object



21
22
23
24
25
# File 'lib/quandl/support/attributes.rb', line 21

def define_attributes(*attribute_names)
  attribute_names.each do |key|
    define_attribute(key)
  end
end

#inherited(subclass) ⇒ Object



17
18
19
# File 'lib/quandl/support/attributes.rb', line 17

def inherited(subclass)
  subclass.define_attributes(*attributes)
end