Class: Rql::Dsl::Context
- Includes:
- Aggregations, Comparisons, Logic, Maths, Orders
- Defined in:
- lib/rql/dsl/context.rb
Instance Attribute Summary collapse
-
#arel ⇒ Object
Returns the value of attribute arel.
-
#model ⇒ Object
Returns the value of attribute model.
-
#scope ⇒ Object
Returns the value of attribute scope.
Instance Method Summary collapse
- #as(name) ⇒ Object
- #build_context(name) ⇒ Object
- #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
#<, #<=, #==, #===, #>, #>=, #end_with?, #in?, #include?, #start_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.
12 13 14 15 16 17 |
# File 'lib/rql/dsl/context.rb', line 12 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 Attribute Details
#arel ⇒ Object
Returns the value of attribute arel.
10 11 12 |
# File 'lib/rql/dsl/context.rb', line 10 def arel @arel end |
#model ⇒ Object
Returns the value of attribute model.
10 11 12 |
# File 'lib/rql/dsl/context.rb', line 10 def model @model end |
#scope ⇒ Object
Returns the value of attribute scope.
10 11 12 |
# File 'lib/rql/dsl/context.rb', line 10 def scope @scope end |
Instance Method Details
#as(name) ⇒ Object
28 29 30 |
# File 'lib/rql/dsl/context.rb', line 28 def as(name) Context.new(@model, arel.as(name.to_s)) end |
#build_context(name) ⇒ Object
23 24 25 26 |
# File 'lib/rql/dsl/context.rb', line 23 def build_context(name) model = @name.to_s.classify.constantize Context.new(model, model.arel_table[name], name) end |
#context_name ⇒ Object
19 20 21 |
# File 'lib/rql/dsl/context.rb', line 19 def context_name @name end |