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.
12 13 14 15 16 17 18 |
# File 'lib/rom/sql/type_dsl.rb', line 12 def initialize(value_type) if value_type.class < ::Dry::Types::Type @definition = value_type else @definition = ::ROM::SQL::Types.Nominal(value_type) end end |
Instance Attribute Details
#definition ⇒ Object (readonly)
9 10 11 |
# File 'lib/rom/sql/type_dsl.rb', line 9 def definition @definition end |
#input_constructor ⇒ Object (readonly)
9 10 11 |
# File 'lib/rom/sql/type_dsl.rb', line 9 def input_constructor @input_constructor end |
#output_constructor ⇒ Object (readonly)
9 10 11 |
# File 'lib/rom/sql/type_dsl.rb', line 9 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.
21 22 23 24 25 26 |
# File 'lib/rom/sql/type_dsl.rb', line 21 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.
29 30 31 |
# File 'lib/rom/sql/type_dsl.rb', line 29 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.
34 35 36 |
# File 'lib/rom/sql/type_dsl.rb', line 34 def output(&block) @output_constructor = block end |