Class: ROM::SQL::TypeDSL
- Inherits:
-
Object
- Object
- ROM::SQL::TypeDSL
- Defined in:
- lib/rom/sql/type_dsl.rb
Overview
Type DSL used by Types.define method
Instance Attribute Summary collapse
- #definition ⇒ Object readonly
- #input_constructor ⇒ Object readonly
- #output_constructor ⇒ Object readonly
Instance Method Summary collapse
- #call(&block) ⇒ Object private
-
#initialize(value_type) ⇒ TypeDSL
constructor
private
A new instance of TypeDSL.
- #input(&block) ⇒ Object private
- #output(&block) ⇒ Object private
Constructor Details
#initialize(value_type) ⇒ TypeDSL
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.
Returns a new instance of TypeDSL.
10 11 12 13 14 15 16 |
# File 'lib/rom/sql/type_dsl.rb', line 10 def initialize(value_type) if value_type.class < ::Dry::Types::Type @definition = value_type else @definition = ::ROM::SQL::Types.Definition(value_type) end end |
Instance Attribute Details
#definition ⇒ Object (readonly)
7 8 9 |
# File 'lib/rom/sql/type_dsl.rb', line 7 def definition @definition end |
#input_constructor ⇒ Object (readonly)
7 8 9 |
# File 'lib/rom/sql/type_dsl.rb', line 7 def input_constructor @input_constructor end |
#output_constructor ⇒ Object (readonly)
7 8 9 |
# File 'lib/rom/sql/type_dsl.rb', line 7 def output_constructor @output_constructor end |
Instance Method Details
#call(&block) ⇒ 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.
19 20 21 22 23 24 |
# File 'lib/rom/sql/type_dsl.rb', line 19 def call(&block) instance_exec(&block) definition.constructor(input_constructor) .(read: definition.constructor(output_constructor)) end |
#input(&block) ⇒ 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.
27 28 29 |
# File 'lib/rom/sql/type_dsl.rb', line 27 def input(&block) @input_constructor = block end |
#output(&block) ⇒ 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.
32 33 34 |
# File 'lib/rom/sql/type_dsl.rb', line 32 def output(&block) @output_constructor = block end |