Class: Reflect::Keyspace
- Inherits:
-
Object
- Object
- Reflect::Keyspace
- Defined in:
- lib/reflect/keyspace.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#description ⇒ Object
Returns the value of attribute description.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#name ⇒ Object
Returns the value of attribute name.
-
#slug ⇒ Object
Returns the value of attribute slug.
-
#statistics_key ⇒ Object
Returns the value of attribute statistics_key.
-
#status ⇒ Object
Returns the value of attribute status.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#append(key, records) ⇒ Object
Appends records to a tablet.
-
#initialize(client, attrs = {}) ⇒ Keyspace
constructor
A new instance of Keyspace.
-
#replace(key, records) ⇒ Object
Replaces the existing records in a tablet with a net set of records.
Constructor Details
#initialize(client, attrs = {}) ⇒ Keyspace
Returns a new instance of Keyspace.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/reflect/keyspace.rb', line 17 def initialize(client, attrs={}) @client = client # If we have fields, we'll need to populate them individually. fields = attrs.delete("fields") attrs['updated_at'] = Time.parse(attrs['updated_at']) if attrs['updated_at'] attrs['created_at'] = Time.parse(attrs['created_at']) if attrs['created_at'] attrs.each do |k, v| self.send("#{k}=".to_s, v) end if fields self.fields = fields.map { |f| Field.new(f) } end end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/reflect/keyspace.rb', line 6 def client @client end |
#created_at ⇒ Object
Returns the value of attribute created_at.
14 15 16 |
# File 'lib/reflect/keyspace.rb', line 14 def created_at @created_at end |
#description ⇒ Object
Returns the value of attribute description.
11 12 13 |
# File 'lib/reflect/keyspace.rb', line 11 def description @description end |
#fields ⇒ Object
Returns the value of attribute fields.
12 13 14 |
# File 'lib/reflect/keyspace.rb', line 12 def fields @fields end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/reflect/keyspace.rb', line 8 def name @name end |
#slug ⇒ Object
Returns the value of attribute slug.
9 10 11 |
# File 'lib/reflect/keyspace.rb', line 9 def slug @slug end |
#statistics_key ⇒ Object
Returns the value of attribute statistics_key.
10 11 12 |
# File 'lib/reflect/keyspace.rb', line 10 def statistics_key @statistics_key end |
#status ⇒ Object
Returns the value of attribute status.
13 14 15 |
# File 'lib/reflect/keyspace.rb', line 13 def status @status end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
15 16 17 |
# File 'lib/reflect/keyspace.rb', line 15 def updated_at @updated_at end |
Instance Method Details
#append(key, records) ⇒ Object
Appends records to a tablet. If the tablet doesn’t exist it will be created.
41 42 43 |
# File 'lib/reflect/keyspace.rb', line 41 def append(key, records) client.put("/v1/keyspaces/"+self.slug+"/tablets/"+key, records) end |
#replace(key, records) ⇒ Object
Replaces the existing records in a tablet with a net set of records.
50 51 52 |
# File 'lib/reflect/keyspace.rb', line 50 def replace(key, records) client.post("/v1/keyspaces/"+self.slug+"/tablets/"+key, records) end |