Sha256: 69d76ad9ff20f03c2158d9068de591226e3cecb45ffba0daf7863bcbec55b009

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

module RailsWorkflow
  class OperationTemplate < ActiveRecord::Base
    include OperationStatus
    include RailsWorkflow::Uuid
    include OperationTemplates::Dependencies
    include OperationTemplates::Assignments
    include OperationTemplates::DefaultBuilder

    belongs_to :process_template, class_name: "RailsWorkflow::ProcessTemplate"
    belongs_to :child_process, class_name: "RailsWorkflow::ProcessTemplate"

    scope :other_operations, ->(process_template_id, operation_template_id) {
      where(process_template_id: process_template_id).
          where.not(id: operation_template_id)
    }


    def other_operations
      OperationTemplate.other_operations(self.process_template_id, self.id)
    end


    class << self
      def types
        RailsWorkflow.config.operation_types
      end
    end



    def operation_class
      get_class(:operation_class, default_class(kind.to_sym))
    end

    def default_type
      RailsWorkflow.config.default_operation_template_type
    end

    private
    def default_class kind
      RailsWorkflow.config.operation_types[kind][:class]
    end

    def get_class symb, default
      begin
        (read_attribute(symb).presence || default).constantize
      rescue
        default.constantize
      end

    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails_workflow-0.3.7 app/models/rails_workflow/operation_template.rb
rails_workflow-0.3.6 app/models/rails_workflow/operation_template.rb
rails_workflow-0.3.5 app/models/rails_workflow/operation_template.rb
rails_workflow-0.3.4 app/models/rails_workflow/operation_template.rb
rails_workflow-0.3.3 app/models/rails_workflow/operation_template.rb
rails_workflow-0.3.2 app/models/rails_workflow/operation_template.rb
rails_workflow-0.3.1 app/models/rails_workflow/operation_template.rb
rails_workflow-0.3.0 app/models/rails_workflow/operation_template.rb