Sha256: 2bd646abd3fc8af20aab2db415b6ef1cbe907a55d342a90f3f7b8cf570bdc7dd

Contents?: true

Size: 748 Bytes

Versions: 9

Compression:

Stored size: 748 Bytes

Contents

module RailsWorkflow
  module StatusDecorator
    extend ActiveSupport::Concern

    included do
      def status
        if object.status
          {
              class: get_label_class(object),
              text: object.get_status_values.assoc(object.status)[1]
          }
        else
          {
              class: nil,
              text: nil
          }
        end

      end

      def get_label_class object
        case object.status
          when object.class::DONE
            'label-success'
          when object.class::IN_PROGRESS..object.class::WAITING
            'label-primary'
          when object.class::ERROR
            'label-danger'
          else
            'label-default'
        end
      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_workflow-0.3.7 app/decorators/rails_workflow/status_decorator.rb
rails_workflow-0.3.6 app/decorators/rails_workflow/status_decorator.rb
rails_workflow-0.3.5 app/decorators/rails_workflow/status_decorator.rb
rails_workflow-0.3.4 app/decorators/rails_workflow/status_decorator.rb
rails_workflow-0.3.3 app/decorators/rails_workflow/status_decorator.rb
rails_workflow-0.3.2 app/decorators/rails_workflow/status_decorator.rb
rails_workflow-0.3.1 app/decorators/rails_workflow/status_decorator.rb
rails_workflow-0.3.0 app/decorators/rails_workflow/status_decorator.rb
rails_workflow-0.2.2 app/decorators/rails_workflow/status_decorator.rb