class Zenaton::Workflows::Version

@abstract Subclass and override {#versions} to create your own versionned workflows

Public Class Methods

new(*args) click to toggle source
# File lib/zenaton/workflows/version.rb, line 22
def initialize(*args)
  @args = args
end

Public Instance Methods

current() click to toggle source

Get the current implementation class @return [Class]

# File lib/zenaton/workflows/version.rb, line 33
def current
  _get_versions[-1]
end
current_implementation() click to toggle source

Returns an instance of the current implementation @return [Zenaton::Interfaces::Workflow]

# File lib/zenaton/workflows/version.rb, line 45
def current_implementation
  current.new(*@args)
end
handle() click to toggle source

Calls handle on the current implementation

# File lib/zenaton/workflows/version.rb, line 27
def handle
  current_implementation.handle
end
initial() click to toggle source

Get the first implementation class @return [Class]

# File lib/zenaton/workflows/version.rb, line 39
def initial
  _get_versions[0]
end
versions() click to toggle source

@return [Array<Class>] an array containing the class name for each version, ordered from the oldest to the most recent version

# File lib/zenaton/workflows/version.rb, line 17
def versions
  raise NotImplemented,
        "Please override the `versions' method in your subclass"
end

Protected Instance Methods

_get_versions() click to toggle source
# File lib/zenaton/workflows/version.rb, line 51
def _get_versions
  raise ExternalError unless versions.is_a? Array
  raise ExternalError unless versions.any?
  versions.each do |version|
    raise ExternalError unless version < Interfaces::Workflow
  end
  versions
end