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
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/voorhees/resource.rb', line 68
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)
value
elsif method_name.to_s =~ /(.+)=$/ && json_attributes.include?($1.to_sym)
build_methods($1, args[1])
else
super
end
end
|
Instance Method Details
#json_attributes ⇒ Object
58
59
60
|
# File 'lib/voorhees/resource.rb', line 58
def json_attributes
@json_attributes ||= @raw_json.keys.collect{|x| x.underscore.to_sym}
end
|
#json_request(options = {}) ⇒ Object
62
63
64
65
66
|
# File 'lib/voorhees/resource.rb', line 62
def json_request(options={})
self.class.json_request(options) do |r|
yield r
end
end
|