Sha256: f390ccf5440f106572f193617ada0a2b558027acaa8bbd5178305147a6a8bf9c
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
# frozen_string_literal: true require 'dry/types/pathname' require 'rom/types' require 'mime/types' module ROM module Files module Types include ROM::Types 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 # Define a foreign key attribute type # # @example with default type # attribute :spec_file, Types.ForeignKey(:spec_files) # # @example with a custom path map # attribute :spec_file, Types.ForeignKey(:spec_files, key: ->(path) { path.pathmap('spec/%X_spec.rb') }) # # @return [Dry::Types::Definition] # # @api public def self.ForeignKey(relation, type = Types::Pathname, map: ->(pathname) { pathname }) super(relation, type.meta(__proc__: map)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rom-files-0.2.0 | lib/rom/files/types.rb |