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

BasicObject::KEEP_METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

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.

Raises:



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

#datasetObject (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