Module: Quandl::Cassandra::Base::Attributes::ClassMethods
- Defined in:
- lib/quandl/cassandra/base/attributes.rb
Instance Method Summary collapse
Instance Method Details
#attribute_names ⇒ Object
38 39 40 |
# File 'lib/quandl/cassandra/base/attributes.rb', line 38 def attribute_names @attribute_names ||= [] end |
#define_attribute(name) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/quandl/cassandra/base/attributes.rb', line 20 def define_attribute(name) name = name.to_sym self.class_eval do define_attribute_methods [name.to_sym] end define_method(name) do read_attribute(name) end define_method("#{name}=") do |value| write_attribute(name, value) end define_method("#{name}?") do read_attribute(name).present? end # store an array of defined attriubte names attribute_names << name unless attribute_names.include?(name) end |
#define_attributes(*names) ⇒ Object
16 17 18 |
# File 'lib/quandl/cassandra/base/attributes.rb', line 16 def define_attributes(*names) Array(names).each{|name| define_attribute(name) } end |