Module: ROM::Files::Plugins::Schema::Contents

Defined in:
lib/rom/files/plugins/schema/contents.rb

Overview

A plugin for automatically adding contents of file to the schema definition

Examples:

Generic DATA field with String type

schema do
  use :contents
end

Specify another type

schema do
  use :contents, type: Types::YAML
end

Specify another name

# using other types
schema do
  use :contents, name: :contents
end

Defined Under Namespace

Modules: DSL

Constant Summary collapse

NAME =
Files::DATA
TYPE =
Types::String

Class Method Summary collapse

Class Method Details

.apply(schema, name: NAME, type: TYPE) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



35
36
37
38
39
40
41
# File 'lib/rom/files/plugins/schema/contents.rb', line 35

def self.apply(schema, name: NAME, type: TYPE)
  contents = type.meta(name: name, source: schema.name, DATA: true)

  schema.attributes.concat(
    schema.class.attributes([contents], schema.attr_class)
  )
end