Class: DatastaxRails::AttributeMethods::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/datastax_rails/attribute_methods/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass, name, coder, options) ⇒ Definition

Returns a new instance of Definition.



5
6
7
8
9
10
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 5

def initialize(klass, name, coder, options)
  @klass  = klass
  @name   = name.to_s
  @lazy   = options.delete(:lazy)
  @coder  = coder.new(options)
end

Instance Attribute Details

#coderObject (readonly)

Returns the value of attribute coder.



4
5
6
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 4

def coder
  @coder
end

#klassObject (readonly)

Returns the value of attribute klass.



4
5
6
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 4

def klass
  @klass
end

#lazyObject (readonly)

Returns the value of attribute lazy.



4
5
6
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 4

def lazy
  @lazy
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 4

def name
  @name
end

Instance Method Details

#indexedObject

Returns :solr, :cassandra, :both, or false



21
22
23
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 21

def indexed
  coder.options[:indexed]
end

#instantiate(record, value) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 12

def instantiate(record, value)
  value = coder.default if value.nil?
  return if value.nil?

  value = coder.decode(value)
  coder.wrap(record, name, value)
end

#typeObject



25
26
27
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 25

def type
  coder.type
end