Class: Sequel::Dataset::Query

Inherits:
BasicObject
Defined in:
lib/sequel/extensions/query.rb

Overview

Proxy object used by Dataset#query.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BasicObject

const_missing

Constructor Details

#initialize(dataset) ⇒ Query

Returns a new instance of Query.



66
67
68
# File 'lib/sequel/extensions/query.rb', line 66

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:



71
72
73
74
75
76
# File 'lib/sequel/extensions/query.rb', line 71

def method_missing(method, *args, &block)
  # Allow calling private methods, so things like raise works
  @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.



64
65
66
# File 'lib/sequel/extensions/query.rb', line 64

def dataset
  @dataset
end