Sha256: 58340f8738701581c8ab6621fa19a9542b754eda766674c4926118b2945a0896

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'active_support/concern'

module RailsWorkflow
  module OperationTemplates
    # = Workflow::ProcessTemplate::Dependenceis
    #
    # Operation dependencies is a set of conditions. Operation can be build if all that
    # dependenceis / conditions are satisfied. This is default implementation of dependenceis
    # which used to build operation dependency on other operations. You can customize dependency
    # for example you can add some additional logic depending on existiong processes / operations
    # or other conditions in your system.
    #

    module Dependencies

      extend ActiveSupport::Concern

      included do
        scope :independent_only, -> { where(dependencies: nil) }

        def dependencies=(dependencies)
          write_attribute(:dependencies, dependencies.to_json.to_s)
        end

        def dependencies
          value = read_attribute(:dependencies)
          if value.present?
            JSON.parse(value)
          else
            []
          end
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_workflow-0.2.1 app/concerns/rails_workflow/operation_templates/dependencies.rb