Class: Chimera::Base
Constant Summary
Constants included
from Indexes
Indexes::SEARCH_EXCLUDE_LIST
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
included
Methods included from Finders
included
included
included
Methods included from GeoIndexes
included
Methods included from Indexes
included
Methods included from Attributes
included
Constructor Details
#initialize(attributes = {}, id = nil, is_new = true) ⇒ Base
Returns a new instance of Base.
77
78
79
80
81
82
83
|
# File 'lib/chimera/base.rb', line 77
def initialize(attributes={},id=nil,is_new=true)
@attributes = attributes
@orig_attributes = @attributes.clone
@id = id
@new = is_new
@sibling_attributes = nil
end
|
Instance Attribute Details
#associations ⇒ Object
Returns the value of attribute associations.
25
26
27
|
# File 'lib/chimera/base.rb', line 25
def associations
@associations
end
|
#attributes ⇒ Object
Returns the value of attribute attributes.
25
26
27
|
# File 'lib/chimera/base.rb', line 25
def attributes
@attributes
end
|
#id ⇒ Object
Returns the value of attribute id.
25
26
27
|
# File 'lib/chimera/base.rb', line 25
def id
@id
end
|
#orig_attributes ⇒ Object
Returns the value of attribute orig_attributes.
25
26
27
|
# File 'lib/chimera/base.rb', line 25
def orig_attributes
@orig_attributes
end
|
#riak_response ⇒ Object
Returns the value of attribute riak_response.
25
26
27
|
# File 'lib/chimera/base.rb', line 25
def riak_response
@riak_response
end
|
#sibling_attributes ⇒ Object
Returns the value of attribute sibling_attributes.
25
26
27
|
# File 'lib/chimera/base.rb', line 25
def sibling_attributes
@sibling_attributes
end
|
Class Method Details
.bucket(keys = false) ⇒ Object
55
56
57
|
# File 'lib/chimera/base.rb', line 55
def self.bucket(keys=false)
self.connection(:riak_raw).bucket(self.bucket_key,keys)
end
|
.bucket_key ⇒ Object
51
52
53
|
# File 'lib/chimera/base.rb', line 51
def self.bucket_key
self.to_s
end
|
.connection(server) ⇒ Object
36
37
38
|
# File 'lib/chimera/base.rb', line 36
def self.connection(server)
Thread.current["Chimera::#{self.to_s}::#{server}::connection"] ||= new_connection(server)
end
|
.new_connection(server) ⇒ Object
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/chimera/base.rb', line 40
def self.new_connection(server)
case server.to_sym
when :redis
Redis.new(self.config[:redis])
when :riak_raw
RiakRaw::Client.new(self.config[:riak_raw][:host], self.config[:riak_raw][:port])
else
nil
end
end
|
.new_uuid ⇒ Object
59
60
61
|
# File 'lib/chimera/base.rb', line 59
def self.new_uuid
UUIDTools::UUID.random_create.to_s
end
|
.use_config(key) ⇒ Object
Instance Method Details
#<=>(obj) ⇒ Object
73
74
75
|
# File 'lib/chimera/base.rb', line 73
def <=>(obj)
self.id.to_s <=> obj.id.to_s
end
|
#==(obj) ⇒ Object
67
68
69
70
71
|
# File 'lib/chimera/base.rb', line 67
def ==(obj)
obj.class.to_s == self.class.to_s &&
!obj.new? && !self.new? &&
obj.id == self.id
end
|
#inspect ⇒ Object
63
64
65
|
# File 'lib/chimera/base.rb', line 63
def inspect
"#<#{self.to_s}: @id=#{self.id}, @new=#{@new}>"
end
|