Class: Reflect::Keyspace

Inherits:
Object
  • Object
show all
Defined in:
lib/reflect/keyspace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clientObject (readonly)

Returns the value of attribute client.



6
7
8
# File 'lib/reflect/keyspace.rb', line 6

def client
  @client
end

#created_atObject

Returns the value of attribute created_at.



14
15
16
# File 'lib/reflect/keyspace.rb', line 14

def created_at
  @created_at
end

#descriptionObject

Returns the value of attribute description.



11
12
13
# File 'lib/reflect/keyspace.rb', line 11

def description
  @description
end

#fieldsObject

Returns the value of attribute fields.



12
13
14
# File 'lib/reflect/keyspace.rb', line 12

def fields
  @fields
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/reflect/keyspace.rb', line 8

def name
  @name
end

#slugObject

Returns the value of attribute slug.



9
10
11
# File 'lib/reflect/keyspace.rb', line 9

def slug
  @slug
end

#statistics_keyObject

Returns the value of attribute statistics_key.



10
11
12
# File 'lib/reflect/keyspace.rb', line 10

def statistics_key
  @statistics_key
end

#statusObject

Returns the value of attribute status.



13
14
15
# File 'lib/reflect/keyspace.rb', line 13

def status
  @status
end

#updated_atObject

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.

Parameters:

  • String

    key the key to create

  • Array|Hash

    records the records to create



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.

Parameters:

  • String

    key the key to create

  • Array|Hash

    records the records to create



50
51
52
# File 'lib/reflect/keyspace.rb', line 50

def replace(key, records)
  client.post("/v1/keyspaces/"+self.slug+"/tablets/"+key, records)
end