Class: Sequel::Dataset::Query
- Inherits:
- BasicObject
- Defined in:
- lib/sequel/extensions/query.rb
Overview
Proxy object used by Dataset#query.
Constant Summary
Constants inherited from BasicObject
Instance Attribute Summary collapse
-
#dataset ⇒ Object
readonly
The current dataset in the query.
Instance Method Summary collapse
-
#initialize(dataset) ⇒ Query
constructor
A new instance of Query.
-
#method_missing(method, *args, &block) ⇒ Object
Replace the query’s dataset with dataset returned by the method call.
Methods inherited from BasicObject
const_missing, remove_methods!
Constructor Details
#initialize(dataset) ⇒ Query
Returns a new instance of Query.
63 64 65 |
# File 'lib/sequel/extensions/query.rb', line 63 def initialize(dataset) @dataset = dataset end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Replace the query’s dataset with dataset returned by the method call.
68 69 70 71 72 |
# File 'lib/sequel/extensions/query.rb', line 68 def method_missing(method, *args, &block) @dataset = @dataset.send(method, *args, &block) raise(Sequel::Error, "method #{method.inspect} did not return a dataset") unless @dataset.is_a?(Dataset) self end |
Instance Attribute Details
#dataset ⇒ Object (readonly)
The current dataset in the query. This changes on each method call.
61 62 63 |
# File 'lib/sequel/extensions/query.rb', line 61 def dataset @dataset end |