Sha256: 5c244164d58250c5748128548bd1e9a5d8c1116ea3e94242103bc0076731be71

Contents?: true

Size: 800 Bytes

Versions: 3

Compression:

Stored size: 800 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

3 entries across 3 versions & 1 rubygems

Version Path
rom-0.4.2 lib/rom/adapter/memory/commands.rb
rom-0.4.1 lib/rom/adapter/memory/commands.rb
rom-0.4.0 lib/rom/adapter/memory/commands.rb