Class: Babik::Selection::Path::ForeignPath
- Inherits:
-
Object
- Object
- Babik::Selection::Path::ForeignPath
- Defined in:
- lib/babik/queryset/lib/selection/path/foreign_path.rb
Overview
Foreign path A foreign path is a succession of associations ending optionally in an operator if operator is not present, equal is supposed.
Direct Known Subclasses
Constant Summary collapse
- RELATIONSHIP_SEPARATOR =
Babik::Selection::Config::RELATIONSHIP_SEPARATOR
- OPERATOR_SEPARATOR =
Babik::Selection::Config::OPERATOR_SEPARATOR
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#selected_field ⇒ Object
readonly
Returns the value of attribute selected_field.
-
#selection_path ⇒ Object
readonly
Returns the value of attribute selection_path.
Instance Method Summary collapse
-
#_initialize_associations ⇒ Object
Initialize associations.
-
#initialize(model, selection_path) ⇒ ForeignPath
constructor
Construct a foreign path A foreign path will be used with a value as a foreign selection to filter a model with foreign conditions.
Constructor Details
#initialize(model, selection_path) ⇒ ForeignPath
Construct a foreign path A foreign path will be used with a value as a foreign selection to filter a model with foreign conditions
32 33 34 35 36 37 38 39 40 |
# File 'lib/babik/queryset/lib/selection/path/foreign_path.rb', line 32 def initialize(model, selection_path) @model = model @selection_path = selection_path.dup @association_path = selection_path.to_s.split(RELATIONSHIP_SEPARATOR) selection_path = @association_path.pop @selected_field, @operator = selection_path.split(OPERATOR_SEPARATOR) @operator ||= 'equal' _initialize_associations end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
17 18 19 |
# File 'lib/babik/queryset/lib/selection/path/foreign_path.rb', line 17 def model @model end |
#selected_field ⇒ Object (readonly)
Returns the value of attribute selected_field.
17 18 19 |
# File 'lib/babik/queryset/lib/selection/path/foreign_path.rb', line 17 def selected_field @selected_field end |
#selection_path ⇒ Object (readonly)
Returns the value of attribute selection_path.
17 18 19 |
# File 'lib/babik/queryset/lib/selection/path/foreign_path.rb', line 17 def selection_path @selection_path end |
Instance Method Details
#_initialize_associations ⇒ Object
Initialize associations
43 44 45 46 |
# File 'lib/babik/queryset/lib/selection/path/foreign_path.rb', line 43 def _initialize_associations @association_chain = Babik::Association::ForeignAssociationChain.new(@model, @association_path, @selection_path) @association_joiner = Babik::QuerySet::Join::AssociationJoiner.new(@association_chain.associations) end |