Module: ROM::Files::Types

Includes:
Types
Defined in:
lib/rom/files/types.rb,
lib/rom/files/extensions/ruby/types.rb,
lib/rom/files/extensions/markdown/types.rb

Defined Under Namespace

Modules: Markdown, Ruby

Constant Summary collapse

Path =
Types::Pathname.meta(primary_key: true)
FileStat =
Dry::Types::Definition[File::Stat].new(File::Stat)
FileType =
Coercible::String.enum('file', 'directory', 'characterSpecial',
'blockSpecial', 'fifo', 'link', 'socket', 'unknown')
MimeType =
Dry::Types::Definition[MIME::Type].new(MIME::Type).optional.constructor do |type|
  MIME::Types[type].first
end

Class Method Summary collapse

Class Method Details

.ForeignKey(relation, type = Types::Pathname, map: ->(pathname) { pathname }) ⇒ Dry::Types::Definition

Define a foreign key attribute type

Examples:

with default type

attribute :spec_file, Types.ForeignKey(:spec_files)

with a custom path map

attribute :spec_file, Types.ForeignKey(:spec_files, key: ->(path) { path.pathmap('spec/%X_spec.rb') })

Returns:

  • (Dry::Types::Definition)


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

def self.ForeignKey(relation, type = Types::Pathname, map: ->(pathname) { pathname })
  super(relation, type.meta(__proc__: map))
end