Class: PostyClient::Resources::Transport
- Defined in:
- lib/posty_client/resources/transport.rb
Instance Attribute Summary
Attributes inherited from Base
#attributes, #errors, #name, #new_resource
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil) ⇒ Transport
constructor
A new instance of Transport.
- #resource_slug ⇒ Object
- #slug ⇒ Object
Methods inherited from Base
#create, #delete, #load, #new_resource?, #request_with_error_handling, #resource_name, resource_name, #save, #update
Constructor Details
#initialize(name = nil) ⇒ Transport
Returns a new instance of Transport.
21 22 23 24 |
# File 'lib/posty_client/resources/transport.rb', line 21 def initialize(name=nil) @name = name load if name end |
Class Method Details
.all ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/posty_client/resources/transport.rb', line 5 def self.all response = RestClient.get([base_uri, resource_name].join('/')) return nil unless response.code == 200 data = JSON.parse(response) data.collect do |datum| model = self.new model.attributes = datum.flatten.last model.new_resource = false model end end |
Instance Method Details
#resource_slug ⇒ Object
30 31 32 |
# File 'lib/posty_client/resources/transport.rb', line 30 def resource_slug [base_uri, 'transports'].join('/') end |
#slug ⇒ Object
26 27 28 |
# File 'lib/posty_client/resources/transport.rb', line 26 def slug [resource_slug, name].join('/') end |