Class: Box::Item
- Inherits:
-
Object
- Object
- Box::Item
- Extended by:
- Forwardable, Memoist
- Defined in:
- lib/box/item.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
Class Method Summary collapse
Instance Method Summary collapse
- #file? ⇒ Boolean
- #folder? ⇒ Boolean
-
#initialize(*args) ⇒ Item
constructor
A new instance of Item.
Constructor Details
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/box/item.rb', line 5 def client @client end |
#metadata ⇒ Object
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/box/item.rb', line 5 def @metadata end |
Class Method Details
.find(id, client = Box.client) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/box/item.rb', line 30 def self.find(id, client = Box.client) response = client.get("#{type.pluralize}/#{id}") self.new(client, response.body) rescue Box::ResourceNotFound => e nil end |
.type ⇒ Object
9 10 11 |
# File 'lib/box/item.rb', line 9 def self.type self.name.demodulize.downcase end |
Instance Method Details
#file? ⇒ Boolean
26 27 28 |
# File 'lib/box/item.rb', line 26 def file? type == 'file' end |
#folder? ⇒ Boolean
22 23 24 |
# File 'lib/box/item.rb', line 22 def folder? type == 'folder' end |