Class: Sensr::SensrObject
- Inherits:
-
Object
- Object
- Sensr::SensrObject
show all
- Defined in:
- lib/sensr/sensr_object.rb
Overview
Instance Method Summary
collapse
Constructor Details
Returns a new instance of SensrObject.
4
5
6
|
# File 'lib/sensr/sensr_object.rb', line 4
def initialize(hash)
self.attributes = hash
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/sensr/sensr_object.rb', line 20
def method_missing(name, *args)
return @hash[name.to_s] if @hash.key?(name.to_s)
if name.to_s =~ /(.*)=$/
att_name = $1
@hash[att_name] = args.first
return
end
super.method_missing(name)
end
|
Instance Method Details
#attributes ⇒ Object
8
9
10
|
# File 'lib/sensr/sensr_object.rb', line 8
def attributes
@hash.clone
end
|
#attributes=(hash) ⇒ Object
12
13
14
|
# File 'lib/sensr/sensr_object.rb', line 12
def attributes=(hash)
@hash = hash.clone
end
|
#id ⇒ Object
16
17
18
|
# File 'lib/sensr/sensr_object.rb', line 16
def id
self.attributes["id"]
end
|