Class: Craftar::Collection
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#offline ⇒ Object
readonly
Returns the value of attribute offline.
-
#resource_uri ⇒ Object
readonly
Returns the value of attribute resource_uri.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts) ⇒ Collection
constructor
A new instance of Collection.
- #save ⇒ Object
- #update(opts) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(opts) ⇒ Collection
Returns a new instance of Collection.
8 9 10 11 12 13 |
# File 'lib/craftar/collection.rb', line 8 def initialize(opts) @name = opts[:name] @uuid = opts[:uuid] @resource_uri = opts[:resource_uri] @offline = opts[:offline] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/craftar/collection.rb', line 3 def name @name end |
#offline ⇒ Object (readonly)
Returns the value of attribute offline.
3 4 5 |
# File 'lib/craftar/collection.rb', line 3 def offline @offline end |
#resource_uri ⇒ Object (readonly)
Returns the value of attribute resource_uri.
3 4 5 |
# File 'lib/craftar/collection.rb', line 3 def resource_uri @resource_uri end |
#uuid ⇒ Object (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_name ⇒ Object
4 5 6 |
# File 'lib/craftar/collection.rb', line 4 def self.craftar_name 'collection' end |
Instance Method Details
#save ⇒ Object
15 16 17 18 19 20 |
# File 'lib/craftar/collection.rb', line 15 def save response = json_call(:post, name: @name, offline: @offline) @uuid = response['uuid'] @resource_uri = response['resource_uri'] self end |
#update(opts) ⇒ Object
22 23 24 25 26 |
# File 'lib/craftar/collection.rb', line 22 def update(opts) response = json_call(:put, { uuid: @uuid, name: opts[:name], offline: opts[:offline]}.select { |_, value| !value.nil? }) @name = response['name'] self end |