module Quandl::Support::Attributes::ClassMethods

Public Instance Methods

attributes() click to toggle source
# File lib/quandl/support/attributes.rb, line 27
def attributes
  @attributes ||= []
end
define_attributes(*attribute_names) click to toggle source
# 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) click to toggle source
# File lib/quandl/support/attributes.rb, line 17
def inherited(subclass)
  subclass.define_attributes(*attributes)
end

Protected Instance Methods

define_attribute(key) click to toggle source
# 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