Sha256: 67fd866102ce43c47439d6a28094cda989aca4902d96023066f9d1428365f5d9

Contents?: true

Size: 790 Bytes

Versions: 1

Compression:

Stored size: 790 Bytes

Contents

module ROM
  class Adapter
    class Memory < Adapter
      module Commands
        class Create < ROM::Commands::Create
          def execute(tuple)
            attributes = input[tuple]
            validator.call(attributes)
            [relation.insert(attributes.to_h).to_a.last]
          end
        end

        class Update < ROM::Commands::Update
          def execute(params)
            attributes = input[params]
            validator.call(attributes)
            relation.map { |tuple| tuple.update(attributes.to_h) }
          end
        end

        class Delete < ROM::Commands::Delete
          def execute
            tuples = target.to_a
            tuples.each { |tuple| relation.delete(tuple) }
            tuples
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-0.5.0 lib/rom/adapter/memory/commands.rb