Class: CassandraRecord::Base
- Inherits:
-
Object
- Object
- CassandraRecord::Base
show all
- Defined in:
- lib/cassandra_record/base.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
19
20
21
|
# File 'lib/cassandra_record/base.rb', line 19
def initialize(attributes={})
@attributes = HashWithIndifferentAccess.new(attributes)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/cassandra_record/base.rb', line 48
def method_missing(method, *args, &block)
if attributes.has_key?(method)
attributes[method]
else
super(method, *args, &block)
end
end
|
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
17
18
19
|
# File 'lib/cassandra_record/base.rb', line 17
def attributes
@attributes
end
|
Class Method Details
.create(attributes) ⇒ Object
8
9
10
|
# File 'lib/cassandra_record/base.rb', line 8
def create(attributes)
new(attributes).create
end
|
.where(attributes = {}) ⇒ Object
12
13
14
|
# File 'lib/cassandra_record/base.rb', line 12
def where(attributes={})
new.where(attributes)
end
|
Instance Method Details
#create ⇒ Object
29
30
31
32
|
# File 'lib/cassandra_record/base.rb', line 29
def create
Statement.create(table_name, columns, values)
self
end
|
#where(options = {}) ⇒ Object
23
24
25
26
27
|
# File 'lib/cassandra_record/base.rb', line 23
def where(options={})
results = Statement.where(table_name, options).map do |attributes|
self.class.new(attributes)
end
end
|