Class: MaponClient::Resources
- Inherits:
-
Object
- Object
- MaponClient::Resources
show all
- Extended by:
- Helpers
- Defined in:
- lib/mapon_client/resources.rb,
lib/mapon_client/resources/fuel_resource.rb,
lib/mapon_client/resources/unit_resource.rb,
lib/mapon_client/resources/user_resource.rb,
lib/mapon_client/resources/route_resource.rb,
lib/mapon_client/resources/driver_resource.rb,
lib/mapon_client/resources/object_resource.rb,
lib/mapon_client/resources/reefer_resource.rb,
lib/mapon_client/resources/company_resource.rb,
lib/mapon_client/resources/tracking_resource.rb,
lib/mapon_client/resources/unit_data_resource.rb,
lib/mapon_client/resources/tachograph_resource.rb,
lib/mapon_client/resources/unit_group_resource.rb,
lib/mapon_client/resources/data_forward_resource.rb,
lib/mapon_client/resources/application_menu_resource.rb
Direct Known Subclasses
ApplicationMenuResource, CompanyResource, DataForwardResource, DriverResource, FuelResource, ObjectResource, ReeferResource, RouteResource, TachographResource, TrackingResource, UnitDataResource, UnitGroupResource, UnitResource, UserResource
Defined Under Namespace
Classes: ApplicationMenuResource, CompanyResource, DataForwardResource, DriverResource, FuelResource, ObjectResource, ReeferResource, RouteResource, TachographResource, TrackingResource, UnitDataResource, UnitGroupResource, UnitResource, UserResource
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Helpers
resource_name
Constructor Details
#initialize(client) ⇒ Resources
Returns a new instance of Resources.
41
42
43
|
# File 'lib/mapon_client/resources.rb', line 41
def initialize(client)
@client = client
end
|
Class Method Details
.descendants ⇒ Object
22
23
24
25
26
27
|
# File 'lib/mapon_client/resources.rb', line 22
def self.descendants
@descendants ||= begin
classes = constants.map { |const_name| const_get(const_name) }
classes.select { |klass| klass.name.end_with?('Resource') }
end
end
|
.generate_action(name:, method: 'get') ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/mapon_client/resources.rb', line 29
def self.generate_action(name:, method: 'get')
class_eval %{
def #{name}(params = {})
raw_response = @client['#{resource_name}/#{name}'].#{method}(
params: with_key(params)
).body
parse_repsonse(raw_response)
end
}
end
|
Instance Method Details
#parse_repsonse(response) ⇒ Object
49
50
51
|
# File 'lib/mapon_client/resources.rb', line 49
def parse_repsonse(response)
@client.parser_class.new(response).parse
end
|
#with_key(params) ⇒ Object
45
46
47
|
# File 'lib/mapon_client/resources.rb', line 45
def with_key(params)
@client.with_key(params)
end
|