Class: TicketingHub::Resource
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- TicketingHub::Resource
- Defined in:
- lib/ticketing_hub/resource.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#id ⇒ Object
Returns the value of attribute id.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #destroy ⇒ Object
- #destroy! ⇒ Object
-
#initialize(client, values, path, id) ⇒ Resource
constructor
A new instance of Resource.
- #update ⇒ Object
- #update!(attributes) ⇒ Object
Constructor Details
#initialize(client, values, path, id) ⇒ Resource
Returns a new instance of Resource.
7 8 9 10 |
# File 'lib/ticketing_hub/resource.rb', line 7 def initialize(client, values, path, id) self.client = client; self.path = path; self.id = id super(values) end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/ticketing_hub/resource.rb', line 5 def client @client end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/ticketing_hub/resource.rb', line 5 def id @id end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/ticketing_hub/resource.rb', line 5 def path @path end |
Instance Method Details
#destroy ⇒ Object
19 20 21 22 23 24 |
# File 'lib/ticketing_hub/resource.rb', line 19 def destroy destroy! attributes return true rescue TicketingHub::UnprocessableEntity return false end |
#destroy! ⇒ Object
33 34 35 36 37 38 |
# File 'lib/ticketing_hub/resource.rb', line 33 def destroy! merge! client.delete "#{path}/#{id}" rescue TicketingHub::UnprocessableEntity => e merge! e.response_body raise e end |
#update ⇒ Object
12 13 14 15 16 17 |
# File 'lib/ticketing_hub/resource.rb', line 12 def update update! attributes return true rescue TicketingHub::UnprocessableEntity return false end |
#update!(attributes) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/ticketing_hub/resource.rb', line 26 def update! attributes merge! client.patch("#{path}/#{id}", attributes) rescue TicketingHub::UnprocessableEntity => e merge! e.response_body raise e end |