Sha256: 69f67343fc1fa27a3b04acf64d62aef5549028a2ab56ddb7cbbbae5bc19c0301

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

class ReRuleOutcome < ActiveRecord::Base
  belongs_to :re_rule

  validates_associated  :re_rule
  validates_presence_of :outcome  
  def validate    
    if outcome == RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE && pipeline_code.blank?
      errors.add(:pipeline_code, "pipeline code required")
    end
  end

  def copy! re_rule_outcome    
    self.outcome = re_rule_outcome.outcome
    self.pipeline_code = re_rule_outcome.pipeline_code
    self
  end

  def equals? re_rule_outcome    
    if outcome != re_rule_outcome.outcome
      return false
    end
      
    if outcome == RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE
      return false unless pipeline_code == re_rule_outcome.pipeline_code
      #TODO check the pipeline equals the pipeline code
    end  
    
    return true    
  end

  def verify
    if outcome == RulesEngine::RuleOutcome::OUTCOME_START_PIPELINE
      return "pipeline code required" if pipeline_code.blank?
      return "outcome pipeline missing" unless RePipeline.find(:first, :conditions => ["code = ?", pipeline_code])
    end
    
    return nil
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rules_engine-0.0.1 rails_generators/templates/app/models/re_rule_outcome.rb