Class: Geotrigger::Application
- Defined in:
- lib/geotrigger/application.rb
Overview
Application objects offer top-level, ORM-ish access to various other model objects, as well as updating of application specific settings.
a = Geotrigger::Application.new client_id: 'abcde', client_secret: '12345'
#=> <Geotrigger::Application ...>
# or
s = Geotrigger::Session.new client_id: 'abcde', client_secret: '12345'
a = Geotrigger::Application.new session: s
#=> <Geotrigger::Application ...>
Instance Attribute Summary
Attributes inherited from Model
Instance Method Summary collapse
-
#devices(params = {}) ⇒ Object
Return an
ArrayofDevicemodel objects that belong to this application. -
#permissions ⇒ Object
Return this application’s default tag permissions as a
Hash. -
#permissions=(perms) ⇒ Object
Update this application’s default tag permissions with a
Hash. -
#tags(params = {}) ⇒ Object
Return an
ArrayofTagmodel objects that belong to this application. -
#triggers(params = {}) ⇒ Object
Return an
ArrayofTriggermodel objects that belong to this application.
Methods inherited from Model
#==, from_api, #initialize, #method_missing, #post_list
Constructor Details
This class inherits a constructor from Geotrigger::Model
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Geotrigger::Model
Instance Method Details
#devices(params = {}) ⇒ Object
Return an Array of Device model objects that belong to this application.
- params
-
Hashoptional parameters to send with the request
a.devices tags: 'foo'
#=> [<Geotrigger::Device ...>, ...] # (devices that have the tag 'foo' on them)
a.devices geo: { geojson: { type: "Feature", properties: nil, geometry: {
type:"Polygon",coordinates:[[[-122.669085113593,45.4999973537201], ... ,[-122.669085113593,45.4999973537201]]]
}}}
#=> [<Geotrigger::Device ...>, ...] # (devices whose last location was inside the given polygon)
51 52 53 |
# File 'lib/geotrigger/application.rb', line 51 def devices params = {} post_list 'devices', params end |
#permissions ⇒ Object
Return this application’s default tag permissions as a Hash.
a.
#=> {"deviceTagging"=>true, "deviceLocation"=>false, ... }
22 23 24 |
# File 'lib/geotrigger/application.rb', line 22 def post 'application/permissions' end |
#permissions=(perms) ⇒ Object
Update this application’s default tag permissions with a Hash.
a. = { deviceTagging: false }
#=> {:deviceTagging => false }
a.
#=> {"deviceTagging"=>false, "deviceLocation"=>false, ... }
34 35 36 |
# File 'lib/geotrigger/application.rb', line 34 def perms post 'application/permissions/update', perms end |
#tags(params = {}) ⇒ Object
Return an Array of Tag model objects that belong to this application.
- params
-
Hashoptional parameters to send with the request
a.
#=> [<Geotrigger::Tag...>, ...]
63 64 65 |
# File 'lib/geotrigger/application.rb', line 63 def params = {} post_list 'tags', params end |
#triggers(params = {}) ⇒ Object
Return an Array of Trigger model objects that belong to this application.
- params
-
Hashoptional parameters to send with the request
a.triggers tags: 'foo'
#=> [<Geotrigger::Trigger ...>, ...] # (triggers that have the tag 'foo' on them)
a.triggers geo: { geojson: { type: "Feature", properties: nil, geometry: {
type:"Polygon",coordinates:[[[-122.669085113593,45.4999973537201], ... ,[-122.669085113593,45.4999973537201]]]
}}}
#=> [<Geotrigger::Trigger ...>, ...] # (triggers whose condition polygon is inside the given polygon)
80 81 82 |
# File 'lib/geotrigger/application.rb', line 80 def triggers params = {} post_list 'triggers', params end |