Class: Rql::Dsl::Context
- Includes:
- Aggregations, Comparisons, Logic, Maths, Orders
- Defined in:
- lib/rql/dsl/context.rb
Instance Method Summary collapse
- #arel ⇒ Object
- #as(name) ⇒ Object
- #build_context(name) ⇒ Object
-
#initialize(scope, arel, name = nil) ⇒ Context
constructor
A new instance of Context.
- #rql ⇒ Object
- #where(*attributes, &block) ⇒ Object
Methods included from Logic
Methods included from Orders
Methods included from Maths
Methods included from Comparisons
#<, #<=, #==, #===, #>, #>=, #ends_with?, #in?, #include?, #starts_with?
Methods included from Aggregations
#average, #calculate, #count, #maximum, #minimum, #sum
Methods inherited from Base
#method_missing, #respond_to_missing?
Constructor Details
#initialize(scope, arel, name = nil) ⇒ Context
Returns a new instance of Context.
10 11 12 13 14 15 |
# File 'lib/rql/dsl/context.rb', line 10 def initialize(scope, arel, name = nil) @scope = scope @model = scope.unscoped @arel = arel @name = name end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rql::Dsl::Base
Instance Method Details
#arel ⇒ Object
17 18 19 |
# File 'lib/rql/dsl/context.rb', line 17 def arel @arel end |
#as(name) ⇒ Object
26 27 28 |
# File 'lib/rql/dsl/context.rb', line 26 def as(name) Context.new(@model, arel.as(name.to_s)) end |
#build_context(name) ⇒ Object
21 22 23 24 |
# File 'lib/rql/dsl/context.rb', line 21 def build_context(name) model = @name.to_s.classify.constantize Context.new(model, model.arel_table[name], name) end |