Sha256: f9cf2a3b5c74e8bb43c1e2e0a21fcc45c7a50747187aad0e8c1e93f4c6768367

Contents?: true

Size: 718 Bytes

Versions: 8

Compression:

Stored size: 718 Bytes

Contents

module Reactor
  module Workflow
    class Standard
      WORKFLOW_ACTIONS = %i(take forward reject commit release sign).freeze

      def initialize(obj, meta_obj)
        @obj = obj
        @meta_obj = meta_obj
      end

      def empty?
        false
      end

      def name
        @meta_obj.workflow_name
      end

      WORKFLOW_ACTIONS.each do |action|
        define_method :"#{action}?" do
          valid_action?(action)
        end

        define_method :"#{action}!" do |*args|
          @obj.send(:crul_obj).send(:"#{action}!", *args)
        end
      end

      protected

      def valid_action?(action)
        @obj.send(:crul_obj).valid_actions.include?(action.to_s)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
infopark_reactor-1.29.1 lib/reactor/workflow/standard.rb
infopark_reactor-1.29.0 lib/reactor/workflow/standard.rb
infopark_reactor-1.28.0 lib/reactor/workflow/standard.rb
infopark_reactor-1.27.0.rc10 lib/reactor/workflow/standard.rb
infopark_reactor-1.27.0.rc9 lib/reactor/workflow/standard.rb
infopark_reactor-1.27.0.rc8 lib/reactor/workflow/standard.rb
infopark_reactor-1.27.0.rc7 lib/reactor/workflow/standard.rb
infopark_reactor-1.27.0.rc4 lib/reactor/workflow/standard.rb