Sha256: f1d5f23e2a25fa384bb834ee2e611037c1ccc8733db10c6aaf8a7757929ee199

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

class Dummy::LocationAPI < IntrospectiveGrape::API
  exclude_actions Location, :none 
  include_actions LocationBeacon, :index 
  include_actions LocationGps, :index

  default_includes Location, :child_locations, :gps, :beacons, :locatables

  filter_on :name, :filter

  restful Location, [:name, :kind,
    {gps_attributes: [:id, :lat, :lng, :alt, :_destroy]},
    {beacons_attributes: [:id, :company_id, :mac_address, :uuid, :major, :minor, :_destroy]},
  ]

  class Locatable < Grape::Entity
    expose :id, :locatable_id, :locatable_type, :updated_at, :created_at
  end

  class LocationBeaconEntity < Grape::Entity
    expose :id, :uuid, :major, :minor, :company_id, :mac_address, :created_at
  end

  class LocationGpsEntity < Grape::Entity
    expose :id, :lat, :lng, :alt, :updated_at
  end

  class ChildLocationEntity < Grape::Entity
    expose :id, :name, :kind, :created_at, :updated_at
  end

  class LocationEntity < Grape::Entity
    expose :id, :name, :kind,  :parent_location_id, :created_at, :updated_at
    expose :locatables,       using: Locatable
    expose :child_locations,  using: ChildLocationEntity
    expose :gps,              using: LocationGpsEntity
    expose :beacons,          using: LocationBeaconEntity
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
introspective_grape-0.2.7 spec/dummy/app/api/dummy/location_api.rb
introspective_grape-0.2.6 spec/dummy/app/api/dummy/location_api.rb
introspective_grape-0.2.5 spec/dummy/app/api/dummy/location_api.rb
introspective_grape-0.2.4 spec/dummy/app/api/dummy/location_api.rb
introspective_grape-0.2.3 spec/dummy/app/api/dummy/location_api.rb
introspective_grape-0.2.2 spec/dummy/app/api/dummy/location_api.rb