Module: Miscellany::ComputedColumns::ActiveRecordRelationPatch
- Defined in:
- lib/miscellany/active_record/computed_columns.rb
Instance Method Summary collapse
Instance Method Details
#with_computed(*args, **kwargs) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/miscellany/active_record/computed_columns.rb', line 28 def with_computed(*args, **kwargs) entries = { **kwargs } args.each do |k| entries[k] = [] end entries.reduce(self) do |query, (k, v)| comp = model.get_defined_computed(k) raise "Undefined ComputedColum :#{k}" if comp.nil? builder = ComputedBuilder.new(all, k, v, &comp) builder.apply(query) end end |