Sha256: 01415e180f3379b647e4d345d8e30caae93953d41e451a7ee6906f939d9ee145

Contents?: true

Size: 673 Bytes

Versions: 6

Compression:

Stored size: 673 Bytes

Contents

module Workflow
  module Adapter
    module Mongoid
      def self.included(klass)
        klass.send :include, InstanceMethods
      end
      module InstanceMethods
        def load_workflow_state
          send(self.class.workflow_column)
        end

        def persist_workflow_state(new_value)
          update_attributes(self.class.workflow_column => new_value)
        end

        def before_validation
          attributes[self.class.workflow_column] = current_state.to_s
          super
        end
      end
    end
  end
end

module Mongoid
  module Document
    module ClassMethods
      def workflow_adapter; Workflow::Adapter::Mongoid end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
grape-gen-0.0.6 template/config/initializers/workflow.rb
grape-gen-0.0.5 template/config/initializers/workflow.rb
grape-gen-0.0.4 template/config/initializers/workflow.rb
grape-gen-0.0.3 template/config/initializers/workflow.rb
grape-gen-0.0.2 template/config/initializers/workflow.rb
grape-gen-0.0.1 template/config/initializers/workflow.rb