Class: Amiando::Resource
- Inherits:
-
Object
- Object
- Amiando::Resource
- Includes:
- Attributes, Autorun
- Defined in:
- lib/amiando/resource.rb
Direct Known Subclasses
ApiKey, Event, Partner, PaymentType, Public::Event, Sync, TicketCategory, TicketShop, TicketType, User
Instance Attribute Summary collapse
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
Class Method Summary collapse
Instance Method Summary collapse
- #==(resource) ⇒ Object
- #extract_attributes_from(response_body, key) ⇒ Object
-
#initialize(attributes = nil) ⇒ Resource
constructor
A new instance of Resource.
- #populate(reponse_body) ⇒ Object
- #populate_create(response_body) ⇒ Object
Methods included from Attributes
#[], #id, included, #method_missing, #respond_to?, #type
Methods included from Autorun
Constructor Details
#initialize(attributes = nil) ⇒ Resource
71 72 73 |
# File 'lib/amiando/resource.rb', line 71 def initialize(attributes = nil) set_attributes(attributes) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Amiando::Attributes
Instance Attribute Details
#request ⇒ Object
Returns the value of attribute request.
6 7 8 |
# File 'lib/amiando/resource.rb', line 6 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/amiando/resource.rb', line 6 def response @response end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
7 8 9 |
# File 'lib/amiando/resource.rb', line 7 def success @success end |
Class Method Details
.method_missing(method_name, *args, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/amiando/resource.rb', line 12 def method_missing(method_name, *args, &block) if match = /sync_(.*)/.match(method_name.to_s) res = self.send(match[1], *args, &block) Amiando.run res else super end end |
Instance Method Details
#==(resource) ⇒ Object
92 93 94 |
# File 'lib/amiando/resource.rb', line 92 def ==(resource) id == resource.id end |
#extract_attributes_from(response_body, key) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/amiando/resource.rb', line 84 def extract_attributes_from(response_body, key) @attributes = {} set_attributes(response_body[key]) @success = response_body['success'] end |
#populate(reponse_body) ⇒ Object
75 76 77 |
# File 'lib/amiando/resource.rb', line 75 def populate(reponse_body) raise Error::NotImplemented.new("populate method not implemented for #{self.class}") end |
#populate_create(response_body) ⇒ Object
79 80 81 82 |
# File 'lib/amiando/resource.rb', line 79 def populate_create(response_body) @attributes = {:id => response_body['id'], :errors => response_body['errors']} @success = response_body['success'] end |