Class: CassandraModel::QueryResult
- Inherits:
-
Object
- Object
- CassandraModel::QueryResult
- Defined in:
- lib/cassandra_model/query_result.rb
Constant Summary collapse
- @@class_cache =
{}
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
- #==(rhs) ⇒ Object
-
#initialize(attributes) ⇒ QueryResult
constructor
A new instance of QueryResult.
Constructor Details
#initialize(attributes) ⇒ QueryResult
Returns a new instance of QueryResult.
7 8 9 |
# File 'lib/cassandra_model/query_result.rb', line 7 def initialize(attributes) @attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/cassandra_model/query_result.rb', line 5 def attributes @attributes end |
Class Method Details
.create(attributes) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/cassandra_model/query_result.rb', line 11 def self.create(attributes) columns = attributes.keys klass = (@@class_cache[columns] ||= Class.new(QueryResult)) result = klass.new(attributes) columns.each { |column| klass.send(:define_method, column.to_sym) { self.attributes[column] } } result end |
Instance Method Details
#==(rhs) ⇒ Object
19 20 21 |
# File 'lib/cassandra_model/query_result.rb', line 19 def ==(rhs) attributes == rhs.attributes end |