28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/cassandra_object/attributes.rb', line 28
def attribute(name, options)
if model_attributes.empty?
self.model_attributes = {}.with_indifferent_access
elsif (model_attributes.size == 2) && model_attributes.include?(:created_at) && model_attributes.include?(:updated_at)
self.model_attributes = self.model_attributes.dup
end
if type_mapping = CassandraObject::Type.get_mapping(options[:type])
converter = type_mapping.converter
expected_type = type_mapping.expected_type
elsif options[:converter]
converter = options[:converter]
expected_type = options[:type]
else
raise "Unknown type #{options[:type]}"
end
model_attributes[name] = Attribute.new(name, converter, expected_type, options.except(:type, :converter))
end
|