Class: DatastaxRails::AttributeMethods::Definition
- Defined in:
- lib/datastax_rails/attribute_methods/definition.rb
Instance Attribute Summary collapse
-
#coder ⇒ Object
readonly
Returns the value of attribute coder.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
-
#lazy ⇒ Object
readonly
Returns the value of attribute lazy.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#indexed ⇒ Object
Returns :solr, :cassandra, :both, or
false
. -
#initialize(klass, name, coder, options) ⇒ Definition
constructor
A new instance of Definition.
- #instantiate(record, value) ⇒ Object
- #type ⇒ Object
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, ) @klass = klass @name = name.to_s @lazy = .delete(:lazy) @coder = coder.new() end |
Instance Attribute Details
#coder ⇒ Object (readonly)
Returns the value of attribute coder.
4 5 6 |
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 4 def coder @coder end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
4 5 6 |
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 4 def klass @klass end |
#lazy ⇒ Object (readonly)
Returns the value of attribute lazy.
4 5 6 |
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 4 def lazy @lazy end |
#name ⇒ Object (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
#indexed ⇒ Object
Returns :solr, :cassandra, :both, or false
21 22 23 |
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 21 def indexed coder.[: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 |
#type ⇒ Object
25 26 27 |
# File 'lib/datastax_rails/attribute_methods/definition.rb', line 25 def type coder.type end |