Class: Babik::Selection::ForeignSelection
- Inherits:
-
Path::ForeignPath
- Object
- Path::ForeignPath
- Babik::Selection::ForeignSelection
- Defined in:
- lib/babik/queryset/lib/selection/foreign_selection.rb
Overview
Foreign selection
Constant Summary
Constants inherited from Path::ForeignPath
Path::ForeignPath::OPERATOR_SEPARATOR, Path::ForeignPath::RELATIONSHIP_SEPARATOR
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#selected_field ⇒ Object
readonly
Returns the value of attribute selected_field.
-
#selection_path ⇒ Object
readonly
Returns the value of attribute selection_path.
-
#sql_where_condition ⇒ Object
readonly
Returns the value of attribute sql_where_condition.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#_init_sql_where_condition ⇒ Object
Initialize the SQL condition that will be used on the SQL SELECT.
-
#initialize(model, selection_path, value) ⇒ ForeignSelection
constructor
Create a foreign selection, that is, a filter that is based on a foreign field condition.
Methods inherited from Path::ForeignPath
Constructor Details
#initialize(model, selection_path, value) ⇒ ForeignSelection
Create a foreign selection, that is, a filter that is based on a foreign field condition.
21 22 23 24 25 26 27 |
# File 'lib/babik/queryset/lib/selection/foreign_selection.rb', line 21 def initialize(model, selection_path, value) super(model, selection_path) # If the value is an ActiveRecord model, get its id @value = value @value = @value.id if @value.is_a?(ActiveRecord::Base) _init_sql_where_condition end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
10 11 12 |
# File 'lib/babik/queryset/lib/selection/foreign_selection.rb', line 10 def model @model end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
10 11 12 |
# File 'lib/babik/queryset/lib/selection/foreign_selection.rb', line 10 def operator @operator end |
#selected_field ⇒ Object (readonly)
Returns the value of attribute selected_field.
10 11 12 |
# File 'lib/babik/queryset/lib/selection/foreign_selection.rb', line 10 def selected_field @selected_field end |
#selection_path ⇒ Object (readonly)
Returns the value of attribute selection_path.
10 11 12 |
# File 'lib/babik/queryset/lib/selection/foreign_selection.rb', line 10 def selection_path @selection_path end |
#sql_where_condition ⇒ Object (readonly)
Returns the value of attribute sql_where_condition.
10 11 12 |
# File 'lib/babik/queryset/lib/selection/foreign_selection.rb', line 10 def sql_where_condition @sql_where_condition end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
10 11 12 |
# File 'lib/babik/queryset/lib/selection/foreign_selection.rb', line 10 def value @value end |
Instance Method Details
#_init_sql_where_condition ⇒ Object
Initialize the SQL condition that will be used on the SQL SELECT
30 31 32 33 34 35 36 |
# File 'lib/babik/queryset/lib/selection/foreign_selection.rb', line 30 def _init_sql_where_condition last_association_model = @association_chain.target_model actual_field = Babik::Table::Field.new(last_association_model, @selected_field).real_field @sql_where_condition = Babik::Selection::Operation::Base.factory( "#{target_alias}.#{actual_field}", @operator, @value ) end |