Module: ROM::Types::Methods

Defined in:
core/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)


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

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