Class: Babik::Selection::LocalSelection
- Inherits:
-
Path::LocalPath
- Object
- Path::LocalPath
- Babik::Selection::LocalSelection
- Defined in:
- lib/babik/queryset/lib/selection/local_selection.rb
Overview
Selection by a local field
Constant Summary
Constants inherited from Path::LocalPath
Path::LocalPath::OPERATOR_SEPARATOR
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#secondary_operator ⇒ Object
readonly
Returns the value of attribute secondary_operator.
-
#selected_field ⇒ Object
readonly
Returns the value of attribute selected_field.
-
#selection_path ⇒ Object
readonly
Returns the value of attribute selection_path.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(model, selection_path, value) ⇒ LocalSelection
constructor
Construct a local field selector.
-
#sql_where_condition ⇒ Babik::Selection::Operation::Base
Return the SQL where condition.
Methods inherited from Path::LocalPath
#left_joins_by_alias, #target_alias
Constructor Details
#initialize(model, selection_path, value) ⇒ LocalSelection
Construct a local field selector
20 21 22 23 |
# File 'lib/babik/queryset/lib/selection/local_selection.rb', line 20 def initialize(model, selection_path, value) super(model, selection_path) @value = value end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
12 13 14 |
# File 'lib/babik/queryset/lib/selection/local_selection.rb', line 12 def model @model end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
12 13 14 |
# File 'lib/babik/queryset/lib/selection/local_selection.rb', line 12 def operator @operator end |
#secondary_operator ⇒ Object (readonly)
Returns the value of attribute secondary_operator.
12 13 14 |
# File 'lib/babik/queryset/lib/selection/local_selection.rb', line 12 def secondary_operator @secondary_operator end |
#selected_field ⇒ Object (readonly)
Returns the value of attribute selected_field.
12 13 14 |
# File 'lib/babik/queryset/lib/selection/local_selection.rb', line 12 def selected_field @selected_field end |
#selection_path ⇒ Object (readonly)
Returns the value of attribute selection_path.
12 13 14 |
# File 'lib/babik/queryset/lib/selection/local_selection.rb', line 12 def selection_path @selection_path end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
12 13 14 |
# File 'lib/babik/queryset/lib/selection/local_selection.rb', line 12 def value @value end |
Instance Method Details
#sql_where_condition ⇒ Babik::Selection::Operation::Base
Return the SQL where condition
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/babik/queryset/lib/selection/local_selection.rb', line 27 def sql_where_condition actual_field = Babik::Table::Field.new(model, @selected_field).real_field # Return the condition operator = if @secondary_operator [@operator, @secondary_operator] else @operator end Babik::Selection::Operation::Base.factory("#{self.target_alias}.#{actual_field}", operator, @value) end |