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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/voorhees/resource.rb', line 56
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
46
47
48
|
# File 'lib/voorhees/resource.rb', line 46
def json_attributes
@json_attributes ||= @raw_json.keys.collect{|x| x.to_sym}
end
|
#json_request(klass = nil) ⇒ Object
50
51
52
53
54
|
# File 'lib/voorhees/resource.rb', line 50
def json_request(klass=nil)
self.class.json_request(klass) do |r|
yield r
end
end
|