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