Class: Sensr::Device
- Inherits:
-
SensrObject
- Object
- SensrObject
- Sensr::Device
- Defined in:
- lib/sensr/device.rb
Class Method Summary collapse
-
.find(id) ⇒ Object
Find a device by id ==== Attributes *
id
id of the device to be returned.
Instance Method Summary collapse
-
#initialize(id, hash) ⇒ Device
constructor
:nodoc:.
-
#save ⇒ Object
Save any updated device attributes.
Methods inherited from SensrObject
#attributes, #attributes=, #id, #method_missing
Constructor Details
#initialize(id, hash) ⇒ Device
:nodoc:
4 5 6 7 8 |
# File 'lib/sensr/device.rb', line 4 def initialize(id, hash) # :nodoc: new_hash = hash["device"] new_hash["id"] = id if new_hash && new_hash.size > 0 && new_hash["id"].nil? super(new_hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Sensr::SensrObject
Class Method Details
Instance Method Details
#save ⇒ Object
Save any updated device attributes
19 20 21 22 23 24 25 |
# File 'lib/sensr/device.rb', line 19 def save response = Sensr.request(:put, Sensr.api_base_url + '/devices/' + self.attributes["id"].to_s, nil, self.attributes) self.attributes = response["device"] end |