Module: CassandraObject::AttributeMethods
- Extended by:
- ActiveSupport::Autoload, ActiveSupport::Concern
- Includes:
- ActiveModel::AttributeMethods
- Included in:
- Base
- Defined in:
- lib/cassandra_object_rails.rb,
lib/cassandra_object/attribute_methods.rb,
lib/cassandra_object/attribute_methods/dirty.rb,
lib/cassandra_object/attribute_methods/definition.rb,
lib/cassandra_object/attribute_methods/primary_key.rb,
lib/cassandra_object/attribute_methods/typecasting.rb
Defined Under Namespace
Modules: ClassMethods, Dirty, PrimaryKey, Typecasting
Classes: Definition
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args, &block) ⇒ Object
59
60
61
62
63
64
65
66
|
# File 'lib/cassandra_object/attribute_methods.rb', line 59
def method_missing(method_id, *args, &block)
if !self.class.attribute_methods_generated?
self.class.define_attribute_methods
send(method_id, *args, &block)
else
super
end
end
|
Instance Method Details
#attribute_exists?(name) ⇒ Boolean
45
46
47
|
# File 'lib/cassandra_object/attribute_methods.rb', line 45
def attribute_exists?(name)
@attributes.key?(name.to_s)
end
|
#attributes ⇒ Object
49
50
51
|
# File 'lib/cassandra_object/attribute_methods.rb', line 49
def attributes
Hash[@attributes.map { |name, _| [name, read_attribute(name)] }]
end
|
#attributes=(attributes) ⇒ Object
53
54
55
56
57
|
# File 'lib/cassandra_object/attribute_methods.rb', line 53
def attributes=(attributes)
attributes.each do |(name, value)|
send("#{name}=", value)
end
end
|
#read_attribute(name) ⇒ Object
41
42
43
|
# File 'lib/cassandra_object/attribute_methods.rb', line 41
def read_attribute(name)
@attributes[name.to_s]
end
|
#respond_to?(*args) ⇒ Boolean
68
69
70
71
|
# File 'lib/cassandra_object/attribute_methods.rb', line 68
def respond_to?(*args)
self.class.define_attribute_methods unless self.class.attribute_methods_generated?
super
end
|
#write_attribute(name, value) ⇒ Object
37
38
39
|
# File 'lib/cassandra_object/attribute_methods.rb', line 37
def write_attribute(name, value)
@attributes[name.to_s] = self.class.typecast_attribute(self, name, value)
end
|