Module: Workflow::StateDependentValidations::StateDependency

Defined in:
lib/workflow/state_dependent_validations.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/workflow/state_dependent_validations.rb', line 7

def self.included(base)
  base.prepend Module.new do
    def validate(record)
      if not record.respond_to?(:current_state) or
          perform_validation_for_state?(record.current_state) or
          perform_validation_for_transition?(record.in_transition) or
          perform_validation_for_transition?("#{record.in_exit}_exit") or
          perform_validation_for_transition?("#{record.in_entry}_entry")
        super(record)
      end
    end
  end
end