Module: ROM::Types::Methods

Defined in:
lib/rom/types.rb

Overview

Type extensions

Instance Method Summary collapse

Instance Method Details

#ForeignKey(relation, type = Types::Integer) ⇒ Dry::Types::Nominal

Shortcut for defining a foreign key attribute type

Parameters:

  • relation (Symbol)

    The name of the target relation

  • type (Object) (defaults to: Types::Integer)

    The type of an attribute

Returns:

  • (Dry::Types::Nominal)


32
33
34
# File 'lib/rom/types.rb', line 32

def ForeignKey(relation, type = Types::Integer)
  type.meta(foreign_key: true, target: relation)
end