Class: StandardConfig::Schema::FieldDefinition
- Inherits:
-
Object
- Object
- StandardConfig::Schema::FieldDefinition
- Defined in:
- lib/standard_config/schema.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#readonly ⇒ Object
readonly
Returns the value of attribute readonly.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #default_value ⇒ Object
-
#initialize(name, type: :string, default: nil, readonly: false) ⇒ FieldDefinition
constructor
A new instance of FieldDefinition.
Constructor Details
#initialize(name, type: :string, default: nil, readonly: false) ⇒ FieldDefinition
Returns a new instance of FieldDefinition.
93 94 95 96 97 98 |
# File 'lib/standard_config/schema.rb', line 93 def initialize(name, type: :string, default: nil, readonly: false) @name = name.to_sym @type = type @default = default @readonly = readonly end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
91 92 93 |
# File 'lib/standard_config/schema.rb', line 91 def default @default end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
91 92 93 |
# File 'lib/standard_config/schema.rb', line 91 def name @name end |
#readonly ⇒ Object (readonly)
Returns the value of attribute readonly.
91 92 93 |
# File 'lib/standard_config/schema.rb', line 91 def readonly @readonly end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
91 92 93 |
# File 'lib/standard_config/schema.rb', line 91 def type @type end |
Instance Method Details
#default_value ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/standard_config/schema.rb', line 100 def default_value if @default.respond_to?(:call) @default.call elsif @default.is_a?(Array) @default.dup else @default end end |