Sha256: 9d57a8ef82a3ddce9f0000d90dfc4cf43738b749cee152d368f01e1888f71a6d

Contents?: true

Size: 520 Bytes

Versions: 3

Compression:

Stored size: 520 Bytes

Contents

module Arel
  class Session
    @instance = nil

    def self.instance
      @instance || new
    end

    def self.start
      @instance ||= new
      yield @instance
    ensure
      @instance = nil
    end

    def create(insert)
      insert.call
    end

    def read(select)
      @read ||= {}
      key = select.object_id
      return @read[key] if @read.key? key
      @read[key] = select.call
    end

    def update(update)
      update.call
    end

    def delete(delete)
      delete.call
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arel-1.0.1 lib/arel/session.rb
arel-1.0.0 lib/arel/session.rb
arel-1.0.0.rc1 lib/arel/session.rb