Sha256: 2152a01902f65a0e9115e41d0416a618c8fc3c05aefed2805bb36c755a14f05c

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8

module ROM
  class Session

    # @api private
    class State
      include Concord::Public.new(:object, :mapper)

      TransitionError = Class.new(StandardError)

      # @api private
      def save(*)
        raise TransitionError, "cannot save object with #{self.class} state"
      end

      # @api private
      def delete(*)
        raise TransitionError, "cannot delete object with #{self.class} state"
      end

      # @api private
      def update(*)
        raise TransitionError, "cannot update object with #{self.class} state"
      end

      # @api private
      def transient?
        instance_of?(Transient)
      end

      # @api private
      def created?
        instance_of?(Created)
      end

      # @api private
      def persisted?
        instance_of?(Persisted)
      end

      # @api private
      def updated?
        instance_of?(Updated)
      end

      # @api private
      def deleted?
        instance_of?(Deleted)
      end

      # @api private
      def identity
        mapper.identity(object)
      end
    end # State

  end # Session
end # ROM

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-0.2.0 lib/rom/session/state.rb