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.



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

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.



89
90
91
# File 'lib/standard_config/schema.rb', line 89

def default
  @default
end

#nameObject (readonly)

Returns the value of attribute name.



89
90
91
# File 'lib/standard_config/schema.rb', line 89

def name
  @name
end

#readonlyObject (readonly)

Returns the value of attribute readonly.



89
90
91
# File 'lib/standard_config/schema.rb', line 89

def readonly
  @readonly
end

#typeObject (readonly)

Returns the value of attribute type.



89
90
91
# File 'lib/standard_config/schema.rb', line 89

def type
  @type
end

Instance Method Details

#default_valueObject



98
99
100
101
102
103
104
105
106
# File 'lib/standard_config/schema.rb', line 98

def default_value
  if @default.respond_to?(:call)
    @default.call
  elsif @default.is_a?(Array)
    @default.dup
  else
    @default
  end
end