Class: Craftar::Collection

Inherits:
Base
  • Object
show all
Defined in:
lib/craftar/collection.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

create, #destroy, find, list

Constructor Details

#initialize(opts) ⇒ Collection

Returns a new instance of Collection.



8
9
10
11
12
# File 'lib/craftar/collection.rb', line 8

def initialize(opts)
  @name = opts[:name]
  @uuid = opts[:uuid]
  @resource_uri = opts[:resource_uri]
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/craftar/collection.rb', line 3

def name
  @name
end

#resource_uriObject (readonly)

Returns the value of attribute resource_uri.



3
4
5
# File 'lib/craftar/collection.rb', line 3

def resource_uri
  @resource_uri
end

#uuidObject (readonly)

Returns the value of attribute uuid.



3
4
5
# File 'lib/craftar/collection.rb', line 3

def uuid
  @uuid
end

Class Method Details

.craftar_nameObject



4
5
6
# File 'lib/craftar/collection.rb', line 4

def self.craftar_name
  'collection'
end

Instance Method Details

#saveObject



14
15
16
17
18
19
# File 'lib/craftar/collection.rb', line 14

def save
  response = json_call(:post, name: @name)
  @uuid = response['uuid']
  @resource_uri = response['resource_uri']
  self
end

#update(opts) ⇒ Object



21
22
23
24
25
# File 'lib/craftar/collection.rb', line 21

def update(opts)
  response = json_call(:put, { uuid: @uuid, name: opts[:name] }.select { |_, value| !value.nil? })
  @name = response['name']
  self
end