Class: Babik::Selection::SelectRelatedSelection
- Inherits:
-
Object
- Object
- Babik::Selection::SelectRelatedSelection
- Defined in:
- lib/babik/queryset/lib/selection/select_related_selection.rb
Overview
Abstraction of a selection used in select_related operation
Constant Summary collapse
- RELATIONSHIP_SEPARATOR =
Babik::Selection::Config::RELATIONSHIP_SEPARATOR
Instance Attribute Summary collapse
-
#association_path ⇒ Object
readonly
Returns the value of attribute association_path.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#selection_path ⇒ Object
readonly
Returns the value of attribute selection_path.
-
#target_model ⇒ Object
readonly
Returns the value of attribute target_model.
Instance Method Summary collapse
- #_initialize_associations ⇒ Object
-
#initialize(model, selection_path) ⇒ SelectRelatedSelection
constructor
A new instance of SelectRelatedSelection.
Constructor Details
#initialize(model, selection_path) ⇒ SelectRelatedSelection
Returns a new instance of SelectRelatedSelection.
21 22 23 24 25 26 27 28 29 |
# File 'lib/babik/queryset/lib/selection/select_related_selection.rb', line 21 def initialize(model, selection_path) @model = model @selection_path = selection_path.dup @association_path = selection_path.to_s.split(RELATIONSHIP_SEPARATOR) @id = @association_path.join('__') _initialize_associations @target_model = @association_chain.target_model end |
Instance Attribute Details
#association_path ⇒ Object (readonly)
Returns the value of attribute association_path.
16 17 18 |
# File 'lib/babik/queryset/lib/selection/select_related_selection.rb', line 16 def association_path @association_path end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
16 17 18 |
# File 'lib/babik/queryset/lib/selection/select_related_selection.rb', line 16 def id @id end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
16 17 18 |
# File 'lib/babik/queryset/lib/selection/select_related_selection.rb', line 16 def model @model end |
#selection_path ⇒ Object (readonly)
Returns the value of attribute selection_path.
16 17 18 |
# File 'lib/babik/queryset/lib/selection/select_related_selection.rb', line 16 def selection_path @selection_path end |
#target_model ⇒ Object (readonly)
Returns the value of attribute target_model.
16 17 18 |
# File 'lib/babik/queryset/lib/selection/select_related_selection.rb', line 16 def target_model @target_model end |
Instance Method Details
#_initialize_associations ⇒ Object
31 32 33 34 |
# File 'lib/babik/queryset/lib/selection/select_related_selection.rb', line 31 def _initialize_associations @association_chain = Babik::Association::SelectRelatedAssociationChain.new(@model, @association_path, @selection_path) @association_joiner = Babik::QuerySet::Join::AssociationJoiner.new(@association_chain.associations) end |