anjlab/triggerable

View on GitHub
lib/triggerable/rules/rule.rb

Summary

Maintainability
A
0 mins
Test Coverage
module Triggerable
  module Rules
    class Rule
      attr_accessor :name, :model, :condition, :actions

      def initialize model, options, block
        @model     = model
        @condition = Conditions::Condition.build(options[:if])
        @name      = options[:name]
        @actions   = Triggerable::Actions::Action.build(block || options[:do])
      end

      protected

      def desc
        "#{self.class.name} #{name || self}(#{model})"
      end

      def debug?
        Triggerable::Engine.debug
      end
    end
  end
end