Module: CassandraObject::AttributeMethods

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern
Includes:
ActiveModel::AttributeMethods
Included in:
Base
Defined in:
lib/gotime-cassandra_object.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



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

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

Returns:

  • (Boolean)


50
51
52
# File 'lib/cassandra_object/attribute_methods.rb', line 50

def attribute_exists?(name)
  @attributes.key?(name.to_s)
end

#attributesObject



54
55
56
57
58
59
60
# File 'lib/cassandra_object/attribute_methods.rb', line 54

def attributes
  results = {}
  @attributes.each_key do |key|
    results[key] = read_attribute(key)
  end
  results
end

#attributes=(attributes) ⇒ Object



62
63
64
65
66
# File 'lib/cassandra_object/attribute_methods.rb', line 62

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

#read_attribute(name) ⇒ Object



46
47
48
# File 'lib/cassandra_object/attribute_methods.rb', line 46

def read_attribute(name)
  @attributes[name.to_s]
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


77
78
79
80
# File 'lib/cassandra_object/attribute_methods.rb', line 77

def respond_to?(*args)
  self.class.define_attribute_methods unless self.class.attribute_methods_generated?
  super
end

#write_attribute(name, value) ⇒ Object



42
43
44
# File 'lib/cassandra_object/attribute_methods.rb', line 42

def write_attribute(name, value)
  @attributes[name.to_s] = self.class.typecast_attribute(self, name, value)
end