Module: Newflow
- Defined in:
- lib/newflow.rb,
lib/newflow/state.rb,
lib/newflow/trigger.rb,
lib/newflow/workflow.rb,
lib/newflow/transition.rb
Overview
TODO: Allow workflows to identify themselves (for logging and stuffs)
Defined Under Namespace
Modules: ActiveRecordInstantiator, ClassMethods, InstanceMethods, NonActiveRecordInstantiator Classes: InvalidStateDefinitionError, InvalidWorkflowStateError, State, Transition, Trigger, Workflow
Constant Summary collapse
- WITH_SIDE_EFFECTS =
true- WITHOUT_SIDE_EFFECTS =
false
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/newflow.rb', line 24 def self.included(base) base.send(:include, InstanceMethods) if base.ancestors.map {|a| a.to_s }.include?("ActiveRecord::Base") base.send(:include, ActiveRecordInstantiator) else base.send(:include, NonActiveRecordInstantiator) end base.send(:extend, ClassMethods, Forwardable) base.def_delegators :workflow, :transition!, :transition_once!, :current_state, :current_state=, :would_transition_to end |
.logger ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/newflow.rb', line 86 def self.logger return @logger if @logger @logger = if defined?(Rails) Rails.logger else Logger.new(File.open('/dev/null', 'w')) end end |