Class: NumberedRelationships::HasManyConstructor
Instance Method Summary
collapse
Methods inherited from Constructor
#initialize
Instance Method Details
#construct ⇒ Object
5
6
7
8
9
|
# File 'lib/numbered_relationships/has_many.rb', line 5
def construct
super
return construct_has_many_filtered unless @filters.empty?
construct_has_many_unfiltered
end
|
#construct_has_many_filtered ⇒ Object
16
17
18
19
20
21
|
# File 'lib/numbered_relationships/has_many.rb', line 16
def construct_has_many_filtered
@klass.joins(association)
.merge(eval("#{constantize_klass}.#{chain_symbols(@filters)}"))
.group("#{table}.id")
.having("count(#{association.to_s}.id) #{@operator} #{@n}")
end
|
#construct_has_many_unfiltered ⇒ Object
10
11
12
13
14
|
# File 'lib/numbered_relationships/has_many.rb', line 10
def construct_has_many_unfiltered
@klass.joins(association)
.group("#{table}.id")
.having("count(#{association.to_s}.id) #{@operator} #{@n}")
end
|