Class: CassandraObject::Attribute
- Inherits:
-
Object
- Object
- CassandraObject::Attribute
- Defined in:
- lib/cassandra_object/attributes.rb
Instance Attribute Summary collapse
-
#converter ⇒ Object
readonly
Returns the value of attribute converter.
-
#expected_type ⇒ Object
readonly
Returns the value of attribute expected_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #check_value!(value) ⇒ Object
-
#initialize(name, converter, expected_type, options) ⇒ Attribute
constructor
A new instance of Attribute.
Constructor Details
#initialize(name, converter, expected_type, options) ⇒ Attribute
Returns a new instance of Attribute.
4 5 6 7 8 9 |
# File 'lib/cassandra_object/attributes.rb', line 4 def initialize(name, converter, expected_type, ) @name = name.to_s @converter = converter @expected_type = expected_type @options = end |
Instance Attribute Details
#converter ⇒ Object (readonly)
Returns the value of attribute converter.
3 4 5 |
# File 'lib/cassandra_object/attributes.rb', line 3 def converter @converter end |
#expected_type ⇒ Object (readonly)
Returns the value of attribute expected_type.
3 4 5 |
# File 'lib/cassandra_object/attributes.rb', line 3 def expected_type @expected_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/cassandra_object/attributes.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/cassandra_object/attributes.rb', line 3 def @options end |
Instance Method Details
#check_value!(value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/cassandra_object/attributes.rb', line 11 def check_value!(value) return value if value.nil? if value.kind_of?(expected_type) value elsif converter.method(:decode).arity == 1 converter.decode(value) else converter.decode(value, @options) end end |