Module: CassandraObject::Attributes

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::AttributeMethods
Included in:
Base
Defined in:
lib/cassandra_object/attributes.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#attributes=(attributes) ⇒ Object



79
80
81
82
83
# File 'lib/cassandra_object/attributes.rb', line 79

def attributes=(attributes)
  attributes.each do |(name, value)|
    send("#{name}=", value)
  end
end

#read_attribute(name) ⇒ Object Also known as: _read_attribute



68
69
70
71
72
73
74
75
# File 'lib/cassandra_object/attributes.rb', line 68

def read_attribute(name)
  name = name.to_s
  if name == 'id'
    id
  else
    @attributes[name]
  end
end

#write_attribute(name, value) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/cassandra_object/attributes.rb', line 60

def write_attribute(name, value)
  if ma = self.class.model_attributes[name]
    @attributes[name.to_s] = ma.check_value!(value)
  else
    raise NoMethodError, "Unknown attribute #{name.inspect}"
  end
end