Class: Tumblr::Query
- Inherits:
-
Object
- Object
- Tumblr::Query
- Defined in:
- lib/tumblr/query.rb
Defined Under Namespace
Modules: DelegateMethods
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(*parameters, &block) ⇒ Query
constructor
A new instance of Query.
- #method_missing(method, *args, &block) ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(*parameters, &block) ⇒ Query
Returns a new instance of Query.
11 12 13 14 15 |
# File 'lib/tumblr/query.rb', line 11 def initialize(*parameters, &block) @params = {} @param_keys = parameters.to_a @fetch_block = block end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/tumblr/query.rb', line 35 def method_missing(method, *args, &block) if @param_keys.include?(method.to_sym) value = args.length == 1 ? args.first : args @array = nil if value != @params[method.to_sym] @params[method.to_sym] = value self elsif to_a.respond_to?(method) to_a.send(method, *args, &block) else super(method, *args, &block) end end |