Module: Dase::ARRelationInstanceMethods
- Defined in:
- lib/dase/mp_active_record.rb
Instance Method Summary collapse
Instance Method Details
#dase_values ⇒ Object
3 4 5 |
# File 'lib/dase/mp_active_record.rb', line 3 def dase_values @dase_values ||= {} end |
#includes_count_of(*args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dase/mp_active_record.rb', line 7 def includes_count_of(*args) = args. (args, ) return self if args.empty? clone.tap do |relation| args.each do |arg| counter_name = ([:as] || "#{arg}_count").to_sym relation.dase_values[counter_name] = .merge(as: counter_name, association: arg.to_sym) end end end |
#merge(other) ⇒ Object
19 20 21 22 23 |
# File 'lib/dase/mp_active_record.rb', line 19 def merge(other) super(other).tap do |result| result.dase_values.merge!(other.dase_values || {}) if other # other == nil is fine too end end |