Sha256: c19f837b53d3569c23c7d8a2d0a16ca580fadd7f45d16a0e696a99bf5319e51c

Contents?: true

Size: 1.23 KB

Versions: 26

Compression:

Stored size: 1.23 KB

Contents

require 'rom/memory/types'
require 'rom/memory/schema'

module ROM
  module Memory
    # Relation subclass for memory adapter
    #
    # @example
    #   class Users < ROM::Relation[:memory]
    #   end
    #
    # @api public
    class Relation < ROM::Relation
      include Enumerable
      include Memory

      adapter :memory
      schema_class Memory::Schema

      forward :take, :join, :restrict, :order

      # Project a relation with provided attribute names
      #
      # @param [*Array] names A list with attribute names
      #
      # @return [Memory::Relation]
      #
      # @api public
      def project(*names)
        schema.project(*names).(self)
      end

      # Insert tuples into the relation
      #
      # @example
      #   users.insert(name: 'Jane')
      #
      # @return [Relation]
      #
      # @api public
      def insert(*args)
        dataset.insert(*args)
        self
      end
      alias_method :<<, :insert

      # Delete tuples from the relation
      #
      # @example
      #   users.insert(name: 'Jane')
      #   users.delete(name: 'Jane')
      #
      # @return [Relation]
      #
      # @api public
      def delete(*args)
        dataset.delete(*args)
        self
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
rom-core-4.0.2 lib/rom/memory/relation.rb
rom-core-4.0.1 lib/rom/memory/relation.rb
rom-3.3.3 lib/rom/memory/relation.rb
rom-core-4.0.0 lib/rom/memory/relation.rb
rom-3.3.2 lib/rom/memory/relation.rb
rom-core-4.0.0.rc2 lib/rom/memory/relation.rb
rom-core-4.0.0.rc1 lib/rom/memory/relation.rb
rom-core-4.0.0.beta3 lib/rom/memory/relation.rb
rom-3.3.1 lib/rom/memory/relation.rb
rom-core-4.0.0.beta2 lib/rom/memory/relation.rb
rom-3.3.0 lib/rom/memory/relation.rb
rom-core-4.0.0.beta1 lib/rom/memory/relation.rb
rom-3.2.3 lib/rom/memory/relation.rb
rom-3.2.2 lib/rom/memory/relation.rb
rom-3.2.1 lib/rom/memory/relation.rb
rom-3.2.0 lib/rom/memory/relation.rb
rom-3.1.0 lib/rom/memory/relation.rb
rom-3.0.3 lib/rom/memory/relation.rb
rom-3.0.2 lib/rom/memory/relation.rb
rom-3.0.1 lib/rom/memory/relation.rb