Module: Zena::Use::Workflow::ClassMethods
- Defined in:
- lib/zena/use/workflow.rb
Constant Summary collapse
- @@transitions =
FIXME: should use class inheritable attribute
[]
Instance Method Summary collapse
- #add_transition(name, opts, &block) ⇒ Object
- #transitions ⇒ Object
-
#version_class ⇒ Object
Default version class (should usually be overwritten) FIXME: remove !.
Instance Method Details
#add_transition(name, opts, &block) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/zena/use/workflow.rb', line 85 def add_transition(name, opts, &block) v = opts[:from] if v.kind_of?(Symbol) opts[:from] = [Zena::Status[v]] elsif v.kind_of?(Array) opts[:from] = v.map {|e| e.kind_of?(Symbol) ? Zena::Status[e] : e} elsif v.kind_of?(Fixnum) opts[:from] = [v] end v = opts[:to] if v.kind_of?(Symbol) opts[:to] = Zena::Status[v] end self.transitions << opts.merge(:name => name, :validate => block) end |
#transitions ⇒ Object
80 81 82 83 |
# File 'lib/zena/use/workflow.rb', line 80 def transitions @@transitions # something like this does not work: @@transitions[self] ||= [] end |
#version_class ⇒ Object
Default version class (should usually be overwritten) FIXME: remove !
105 106 107 |
# File 'lib/zena/use/workflow.rb', line 105 def version_class Version end |