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.



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.

Raises:



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

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