Class: ProximityBeacon::GoogleResource
- Inherits:
-
Object
- Object
- ProximityBeacon::GoogleResource
show all
- Defined in:
- lib/proximity_beacon/google_resource.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of GoogleResource.
11
12
13
14
15
16
|
# File 'lib/proximity_beacon/google_resource.rb', line 11
def initialize(hash = {})
hash.each do |key, value|
writer = "#{key}="
self.send(writer, value) if respond_to?(writer)
end
end
|
Class Attribute Details
.json_attrs ⇒ Object
Returns the value of attribute json_attrs.
46
47
48
|
# File 'lib/proximity_beacon/google_resource.rb', line 46
def json_attrs
@json_attrs
end
|
Class Method Details
.camelcase_attr_accessor(*accessors) ⇒ Object
4
5
6
7
8
9
|
# File 'lib/proximity_beacon/google_resource.rb', line 4
def self.camelcase_attr_accessor(*accessors)
accessors.each do |accessor|
attr_accessor accessor
alias_camelized_accessor(accessor)
end
end
|
Instance Method Details
#as_json ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/proximity_beacon/google_resource.rb', line 24
def as_json
Hash[
self.class.json_attrs.map {|attr|
value = send(attr)
if value.nil?
nil
elsif value.is_a? GoogleResource
[attr, value.as_json]
else
[attr, value]
end
}.compact
]
end
|
#to_json ⇒ Object
39
40
41
|
# File 'lib/proximity_beacon/google_resource.rb', line 39
def to_json
as_json.to_json
end
|
#update(hash) ⇒ Object
18
19
20
21
22
|
# File 'lib/proximity_beacon/google_resource.rb', line 18
def update(hash)
hash.each do |key, value|
self.send "#{key}=", value
end
end
|