Class: Fried::Schema::Attribute::DefineMethods
- Inherits:
-
Object
- Object
- Fried::Schema::Attribute::DefineMethods
- Defined in:
- lib/fried/schema/attribute/define_methods.rb
Overview
Define methods based on attributes registered in Definition
Instance Attribute Summary collapse
-
#define_reader ⇒ Object
Returns the value of attribute define_reader.
-
#define_writer ⇒ Object
Returns the value of attribute define_writer.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(attribute_definition, klass) ⇒ AttributeDefinition
Creates methods to read/write attribute with type checking.
-
#initialize ⇒ DefineMethods
constructor
A new instance of DefineMethods.
Constructor Details
#initialize ⇒ DefineMethods
Returns a new instance of DefineMethods.
12 13 14 15 |
# File 'lib/fried/schema/attribute/define_methods.rb', line 12 def initialize self.define_reader = ::Fried::Schema::Attribute::DefineReader.new self.define_writer = ::Fried::Schema::Attribute::DefineWriter.new end |
Instance Attribute Details
#define_reader ⇒ Object
Returns the value of attribute define_reader.
9 10 11 |
# File 'lib/fried/schema/attribute/define_methods.rb', line 9 def define_reader @define_reader end |
#define_writer ⇒ Object
Returns the value of attribute define_writer.
10 11 12 |
# File 'lib/fried/schema/attribute/define_methods.rb', line 10 def define_writer @define_writer end |
Class Method Details
.build ⇒ Object
17 18 19 20 21 22 |
# File 'lib/fried/schema/attribute/define_methods.rb', line 17 def self.build new.tap do |instance| instance.define_reader = ::Fried::Schema::Attribute::DefineReader.build instance.define_writer = ::Fried::Schema::Attribute::DefineWriter.build end end |
.call(attribute_definition, klass) ⇒ Object
24 25 26 27 |
# File 'lib/fried/schema/attribute/define_methods.rb', line 24 def self.call(attribute_definition, klass) instance = build instance.(attribute_definition, klass) end |
Instance Method Details
#call(attribute_definition, klass) ⇒ AttributeDefinition
Creates methods to read/write attribute with type checking
33 34 35 36 37 |
# File 'lib/fried/schema/attribute/define_methods.rb', line 33 def call(attribute_definition, klass) define_reader.(attribute_definition, klass) define_writer.(attribute_definition, klass) attribute_definition end |