Class: Rules::Automation
- Defined in:
- lib/triggerable/rules/automation.rb
Instance Attribute Summary
Attributes inherited from Rule
Instance Method Summary collapse
Methods inherited from Rule
Constructor Details
This class inherits a constructor from Rules::Rule
Instance Method Details
#execute! ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/triggerable/rules/automation.rb', line 3 def execute! table = Arel::Table.new(model.table_name) scope = @condition.scope(table) query = table.where(scope).project(Arel.sql('id')).to_sql ids = ParentModel.connection.execute(query).map { |r| r['id'] } models = model.where(id: ids) models.each {|o| actions.each {|a| a.run_for!(o)} } end |