module Quandl::Cassandra::Base::Attributes::ClassMethods

Public Instance Methods

attribute_names() click to toggle source
# File lib/quandl/cassandra/base/attributes.rb, line 39
def attribute_names
  @attribute_names ||= []
end
define_attribute(name) click to toggle source
# File lib/quandl/cassandra/base/attributes.rb, line 21
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) click to toggle source
# File lib/quandl/cassandra/base/attributes.rb, line 16
def define_attributes(*names)
  Array(names).each{|name| define_attribute(name) }
  Quandl::Logger.info("The attributes for #{self.to_s} are #{Array(names).join(', ')}")
end