Class: Fried::Schema::Attribute::DefineWriter
- Inherits:
-
Object
- Object
- Fried::Schema::Attribute::DefineWriter
- Defined in:
- lib/fried/schema/attribute/define_writer.rb
Overview
Define writer based on attribute Definition with type-checking
Instance Attribute Summary collapse
-
#is ⇒ Object
Returns the value of attribute is.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(definition, klass) ⇒ Definition
Creates write method with type-checking.
-
#initialize ⇒ DefineWriter
constructor
A new instance of DefineWriter.
Constructor Details
#initialize ⇒ DefineWriter
Returns a new instance of DefineWriter.
9 10 11 |
# File 'lib/fried/schema/attribute/define_writer.rb', line 9 def initialize self.is = ::Fried::Typings::Is end |
Instance Attribute Details
#is ⇒ Object
Returns the value of attribute is.
7 8 9 |
# File 'lib/fried/schema/attribute/define_writer.rb', line 7 def is @is end |
Class Method Details
.build ⇒ Object
13 14 15 |
# File 'lib/fried/schema/attribute/define_writer.rb', line 13 def self.build new end |
.call(attribute_definition, klass) ⇒ Object
17 18 19 20 |
# File 'lib/fried/schema/attribute/define_writer.rb', line 17 def self.call(attribute_definition, klass) instance = build instance.(attribute_definition, klass) end |
Instance Method Details
#call(definition, klass) ⇒ Definition
Creates write method with type-checking
26 27 28 29 |
# File 'lib/fried/schema/attribute/define_writer.rb', line 26 def call(definition, klass) is_a = is[definition.type] define_writer(definition, is_a, klass) end |