Sha256: 39b71f971067c0310261c0d9734db313326fc1cb1ebe9b79fe61d742f442f885

Contents?: true

Size: 941 Bytes

Versions: 1

Compression:

Stored size: 941 Bytes

Contents

module Machinist::DataMapper
  class Blueprint < Machinist::Blueprint

    # Make and save an object.
    def make!(attributes = {})
      object = make(attributes)
      object.raise_on_save_failure = true
      object.save
      object.reload
    end

    # Box an object for storage in the warehouse.
    def box(object)
      object.key
    end

    # Unbox an object from the warehouse.
    def unbox(id)
      @klass.find(id)
    end

    # Execute a block on a separate database connection, so that any database
    # operations happen outside any open transactions.
    def outside_transaction
      # ActiveRecord manages connections per-thread, so the only way to
      # convince it to open another connection is to start another thread.
      thread = Thread.new do
        begin
          yield
        end
      end
      thread.value
    end

    def lathe_class #:nodoc:
      Machinist::DataMapper::Lathe
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dm-machinist-0.0.1 lib/machinist/data_mapper/blueprint.rb