Sha256: 4e0d28f185ede017dfb9043a2aa782f2357f6b74df69a8db5de54448897d3fb2

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 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
        serialize :dependencies, JSON

        # dependeing on serialize / rails version it may save null value or 'null' value
        scope :independent_only, -> { where("dependencies is null or dependencies = 'null' or dependencies='[]'") }

        def resolve_dependency operation
          true
        end

        # def dependencies=(dependencies)
        #   write_attribute(:dependencies, dependencies.to_json.to_s)
        # end
        #
        def dependencies
          read_attribute(:dependencies) || []
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_workflow-0.3.7 app/concerns/rails_workflow/operation_templates/dependencies.rb
rails_workflow-0.3.6 app/concerns/rails_workflow/operation_templates/dependencies.rb
rails_workflow-0.3.5 app/concerns/rails_workflow/operation_templates/dependencies.rb