Class: Taro::Types::FieldDef
- Inherits:
-
Object
- Object
- Taro::Types::FieldDef
- Defined in:
- lib/taro/types/field_def.rb
Overview
Lazily-evaluated field definition.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#defined_at ⇒ Object
readonly
Returns the value of attribute defined_at.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #evaluate ⇒ Object
-
#initialize(defined_at: nil, **attributes) ⇒ FieldDef
constructor
A new instance of FieldDef.
- #name ⇒ Object
Constructor Details
#initialize(defined_at: nil, **attributes) ⇒ FieldDef
Returns a new instance of FieldDef.
5 6 7 8 9 |
# File 'lib/taro/types/field_def.rb', line 5 def initialize(defined_at: nil, **attributes) @attributes = attributes @defined_at = defined_at validate end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/taro/types/field_def.rb', line 3 def attributes @attributes end |
#defined_at ⇒ Object (readonly)
Returns the value of attribute defined_at.
3 4 5 |
# File 'lib/taro/types/field_def.rb', line 3 def defined_at @defined_at end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 |
# File 'lib/taro/types/field_def.rb', line 23 def ==(other) other.is_a?(self.class) && attributes == other.attributes end |
#evaluate ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/taro/types/field_def.rb', line 11 def evaluate Taro::Types::Field.new( **attributes.except(*Taro::Types::Coercion.keys), defined_at:, type: Taro::Types::Coercion.call(attributes), ) end |
#name ⇒ Object
19 20 21 |
# File 'lib/taro/types/field_def.rb', line 19 def name attributes[:name] end |