Class: Joshua::RenderProxy
- Inherits:
-
Object
- Object
- Joshua::RenderProxy
- Defined in:
- lib/joshua/render_proxy.rb
Instance Method Summary collapse
-
#initialize(api) ⇒ RenderProxy
constructor
A new instance of RenderProxy.
- #method_missing(method_name, *args) ⇒ Object
Constructor Details
#initialize(api) ⇒ RenderProxy
Returns a new instance of RenderProxy.
11 12 13 |
# File 'lib/joshua/render_proxy.rb', line 11 def initialize api @api = api end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/joshua/render_proxy.rb', line 15 def method_missing method_name, *args # if first param present, it must be resource ID api_id = args.shift unless args.first.is_a?(Hash) # convinience, second param is params hash, options follw params, opts = [args[0], args[1] || {}] # merge id and params to options opts.merge! params: params, id: api_id @api.render method_name, opts end |