Class: StandardConfig::Schema::ScopeBuilder
- Inherits:
-
Object
- Object
- StandardConfig::Schema::ScopeBuilder
- Defined in:
- lib/standard_config/schema.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #field(name, type: :string, default: nil, readonly: false) ⇒ Object
-
#initialize(name) ⇒ ScopeBuilder
constructor
A new instance of ScopeBuilder.
Constructor Details
#initialize(name) ⇒ ScopeBuilder
Returns a new instance of ScopeBuilder.
76 77 78 79 |
# File 'lib/standard_config/schema.rb', line 76 def initialize(name) @name = name.to_sym @fields = Concurrent::Map.new end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
74 75 76 |
# File 'lib/standard_config/schema.rb', line 74 def fields @fields end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
74 75 76 |
# File 'lib/standard_config/schema.rb', line 74 def name @name end |
Instance Method Details
#field(name, type: :string, default: nil, readonly: false) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/standard_config/schema.rb', line 81 def field(name, type: :string, default: nil, readonly: false) key = name.to_sym if @fields.key?(key) Kernel.warn("[StandardId::Configuration] Redefining field '#{key}' in scope '#{@name}'. Last definition wins.") end @fields[key] = FieldDefinition.new(name, type: type, default: default, readonly: readonly) end |