Class: Craftar::CollectionBundle

Inherits:
Base
  • Object
show all
Defined in:
lib/craftar/collection_bundle.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) ⇒ CollectionBundle

Returns a new instance of CollectionBundle.



8
9
10
11
12
13
14
15
16
# File 'lib/craftar/collection_bundle.rb', line 8

def initialize(opts)
  @uuid = opts[:uuid]
  @resource_uri = opts[:resource_uri]
  @app = opts[:app]
  @collection = opts[:collection]
  @version = opts[:version]
  @file = opts[:file]
  @status = opts[:status]
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



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

def app
  @app
end

#collectionObject (readonly)

Returns the value of attribute collection.



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

def collection
  @collection
end

#fileObject (readonly)

Returns the value of attribute file.



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

def file
  @file
end

#resource_uriObject (readonly)

Returns the value of attribute resource_uri.



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

def resource_uri
  @resource_uri
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

#uuidObject (readonly)

Returns the value of attribute uuid.



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

def uuid
  @uuid
end

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Class Method Details

.craftar_nameObject



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

def self.craftar_name
  'collectionbundle'
end

Instance Method Details

#saveObject



18
19
20
21
22
# File 'lib/craftar/collection_bundle.rb', line 18

def save
  response = json_call(:post, app: @app, collection: @collection, version: @version)
  update_attributes(response)
  self
end

#update(opts) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/craftar/collection_bundle.rb', line 24

def update(opts)
  attributes = {
    app: opts[:app],
    collection: opts[:collection],
    version: opts[:version]
  }.select { |_, value| !value.nil? }

  response = json_call(:put, attributes)
  update_attributes(response)
  self
end

#update_attributes(response) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/craftar/collection_bundle.rb', line 36

def update_attributes(response)
  @uuid = response['uuid']
  @app = response['app']
  @collection = response['collection']
  @file = response['file']
  @resource_uri = response['resource_uri']
  @status = response['status']
  @version = response['version']
end