Sha256: ee95f1c9fcc250f04ee098a4d3725a21cf38e2c66c03c76e745a30c881fe43ab

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

require 'bson'

module ROM
  module Mongo

    module Commands

      class Create < ROM::Commands::Create
        alias_method :collection, :relation

        def execute(document)
          collection.insert(document)
          [document]
        end

      end

      class Update < ROM::Commands::Update
        alias_method :set, :call
        alias_method :collection, :relation

        def execute(attributes)
          collection.update_all('$set' => attributes)
          collection.to_a
        end

      end

      class Delete < ROM::Commands::Delete

        def execute
          removed = target.to_a
          target.remove_all
          removed
        end

      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-mongo-0.0.2 lib/rom/mongo/commands.rb