Class: MaponClient::Resources

Inherits:
Object
  • Object
show all
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

Defined Under Namespace

Classes: ApplicationMenuResource, CompanyResource, DataForwardResource, DriverResource, FuelResource, ObjectResource, ReeferResource, RouteResource, TachographResource, TrackingResource, UnitDataResource, UnitGroupResource, UnitResource, UserResource

Constant Summary collapse

AVAILABLE_RESOURCES =
{
  company: CompanyResource,
  unit_group: UnitGroupResource,
  unit: UnitResource,
  unit_data: UnitDataResource,
  route: RouteResource,
  fuel: FuelResource,
  object: ObjectResource,
  user: UserResource,
  driver: DriverResource,
  reefer: ReeferResource,
  tachograph: TachographResource,
  tracking: TrackingResource,
  data_forward: DataForwardResource,
  application_menu: ApplicationMenuResource,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Resources

Returns a new instance of Resources.



35
36
37
38
# File 'lib/mapon_client/resources.rb', line 35

def initialize(client)
  @client = client
  @resources_repository = {}
end

Instance Method Details

#[](resource) ⇒ Object

Raises:



40
41
42
43
44
# File 'lib/mapon_client/resources.rb', line 40

def [](resource)
  return @resources_repository[resource] if @resources_repository[resource]
  raise ResourceNotFound.new(resource) unless AVAILABLE_RESOURCES[resource]
  @resources_repository[resource] = AVAILABLE_RESOURCES[resource].new(@client)
end

#with_key(params) ⇒ Object



46
47
48
# File 'lib/mapon_client/resources.rb', line 46

def with_key(params)
  @client.with_key(params)
end