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.
68 69 70 |
# File 'lib/sequel/extensions/query.rb', line 68 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.
73 74 75 76 77 |
# File 'lib/sequel/extensions/query.rb', line 73 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.
66 67 68 |
# File 'lib/sequel/extensions/query.rb', line 66 def dataset @dataset end |