Class: ConveyClient::Item

Inherits:
Object
  • Object
show all
Defined in:
lib/convey_client/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_item) ⇒ Item

Returns a new instance of Item.



5
6
7
8
9
10
11
# File 'lib/convey_client/item.rb', line 5

def initialize(raw_item)
  self.id = raw_item["id"]
  self.name = raw_item["name"]
  self.bucket = raw_item["bucket"]
  self.template = raw_item["template"]
  self.attributes = raw_item["attributes"]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



13
14
15
16
17
# File 'lib/convey_client/item.rb', line 13

def method_missing(method, *args, &block)
  super unless attributes.keys.include?(method.to_s)

  attributes[method.to_s]["value"]
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



3
4
5
# File 'lib/convey_client/item.rb', line 3

def attributes
  @attributes
end

#bucketObject

Returns the value of attribute bucket.



3
4
5
# File 'lib/convey_client/item.rb', line 3

def bucket
  @bucket
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/convey_client/item.rb', line 3

def id
  @id
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/convey_client/item.rb', line 3

def name
  @name
end

#templateObject

Returns the value of attribute template.



3
4
5
# File 'lib/convey_client/item.rb', line 3

def template
  @template
end