Class: Babik::QuerySet::Where
- Inherits:
-
Object
- Object
- Babik::QuerySet::Where
- Defined in:
- lib/babik/queryset/components/where.rb
Overview
Where conditions
Instance Attribute Summary collapse
-
#exclusion_filters ⇒ Object
readonly
Returns the value of attribute exclusion_filters.
-
#inclusion_filters ⇒ Object
readonly
Returns the value of attribute inclusion_filters.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
Instance Method Summary collapse
- #add_exclusion_filter(filter) ⇒ Object
- #add_inclusion_filter(filter) ⇒ Object
- #exclusion_filters? ⇒ Boolean
- #inclusion_filters? ⇒ Boolean
-
#initialize(model) ⇒ Where
constructor
A new instance of Where.
- #left_joins_by_alias ⇒ Object
Constructor Details
#initialize(model) ⇒ Where
Returns a new instance of Where.
12 13 14 15 16 |
# File 'lib/babik/queryset/components/where.rb', line 12 def initialize(model) @model = model @inclusion_filters = [] @exclusion_filters = [] end |
Instance Attribute Details
#exclusion_filters ⇒ Object (readonly)
Returns the value of attribute exclusion_filters.
10 11 12 |
# File 'lib/babik/queryset/components/where.rb', line 10 def exclusion_filters @exclusion_filters end |
#inclusion_filters ⇒ Object (readonly)
Returns the value of attribute inclusion_filters.
10 11 12 |
# File 'lib/babik/queryset/components/where.rb', line 10 def inclusion_filters @inclusion_filters end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
10 11 12 |
# File 'lib/babik/queryset/components/where.rb', line 10 def model @model end |
Instance Method Details
#add_exclusion_filter(filter) ⇒ Object
26 27 28 |
# File 'lib/babik/queryset/components/where.rb', line 26 def add_exclusion_filter(filter) @exclusion_filters << Babik::QuerySet::Condition.factory(@model, filter) end |
#add_inclusion_filter(filter) ⇒ Object
30 31 32 |
# File 'lib/babik/queryset/components/where.rb', line 30 def add_inclusion_filter(filter) @inclusion_filters << Babik::QuerySet::Condition.factory(@model, filter) end |
#exclusion_filters? ⇒ Boolean
18 19 20 |
# File 'lib/babik/queryset/components/where.rb', line 18 def exclusion_filters? @exclusion_filters.length.positive? end |
#inclusion_filters? ⇒ Boolean
22 23 24 |
# File 'lib/babik/queryset/components/where.rb', line 22 def inclusion_filters? @inclusion_filters.length.positive? end |
#left_joins_by_alias ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/babik/queryset/components/where.rb', line 34 def left_joins_by_alias left_joins_by_alias = {} [@inclusion_filters, @exclusion_filters].flatten.each do |filter| left_joins_by_alias.merge!(filter.left_joins_by_alias) end left_joins_by_alias end |