Module: Voorhees::Resource::InstanceMethods
- Defined in:
- lib/voorhees/resource.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/voorhees/resource.rb', line 55
def method_missing(*args)
method_name = args[0]
if json_attributes.include?(method_name)
value = value_from_json(method_name)
build_methods(method_name, value)
return value
end
if method_name.to_s =~ /(.+)=$/ && json_attributes.include?($1.to_sym)
build_methods($1, args[1])
return
end
super
end
|
Instance Method Details
#json_attributes ⇒ Object
45
46
47
|
# File 'lib/voorhees/resource.rb', line 45
def json_attributes
@json_attributes ||= @raw_json.keys.collect{|x| x.to_sym}
end
|
#json_request ⇒ Object
49
50
51
52
53
|
# File 'lib/voorhees/resource.rb', line 49
def json_request
self.class.json_request do |r|
yield r
end
end
|