Class: StandardConfig::Schema::FieldDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/standard_config/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#defaultObject (readonly)

Returns the value of attribute default.



91
92
93
# File 'lib/standard_config/schema.rb', line 91

def default
  @default
end

#nameObject (readonly)

Returns the value of attribute name.



91
92
93
# File 'lib/standard_config/schema.rb', line 91

def name
  @name
end

#readonlyObject (readonly)

Returns the value of attribute readonly.



91
92
93
# File 'lib/standard_config/schema.rb', line 91

def readonly
  @readonly
end

#typeObject (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_valueObject



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