Class: Fried::Schema::Attribute::Definition
- Defined in:
- lib/fried/schema/attribute/definition.rb
Overview
Value-type holding definition of attribute
Instance Attribute Summary collapse
-
#default ⇒ Object
Any object.
-
#name ⇒ Object
A Symbol.
-
#type ⇒ Object
Any Class or Module, or Typings::Type.
Instance Method Summary collapse
- #extract_default ⇒ Object
-
#instance_variable ⇒ Symbol
Attribute instance variable name (@variable).
-
#reader ⇒ Symbol
Attribute reader method name.
-
#writer ⇒ Symbol
Attribute writer method name.
Methods included from Struct
Instance Attribute Details
#default ⇒ Object
Any object. If a Proc is used, it will be evaluated during initialization
5 6 7 |
# File 'lib/fried/schema/attribute/definition.rb', line 5 def default @default end |
#name ⇒ Object
A Symbol
5 6 7 |
# File 'lib/fried/schema/attribute/definition.rb', line 5 def name @name end |
#type ⇒ Object
Any Class or Module, or Typings::Type
5 6 7 |
# File 'lib/fried/schema/attribute/definition.rb', line 5 def type @type end |
Instance Method Details
#extract_default ⇒ Object
34 35 36 37 |
# File 'lib/fried/schema/attribute/definition.rb', line 34 def extract_default return default.() if default.is_a?(::Proc) default end |
#instance_variable ⇒ Symbol
Attribute instance variable name (@variable)
28 29 30 |
# File 'lib/fried/schema/attribute/definition.rb', line 28 def instance_variable :"@#{reader}" end |
#reader ⇒ Symbol
Attribute reader method name
16 17 18 |
# File 'lib/fried/schema/attribute/definition.rb', line 16 def reader name.to_sym end |
#writer ⇒ Symbol
Attribute writer method name
22 23 24 |
# File 'lib/fried/schema/attribute/definition.rb', line 22 def writer :"#{reader}=" end |