Class: StandardId::ConfigSchema::DSL
- Inherits:
-
Object
- Object
- StandardId::ConfigSchema::DSL
- Defined in:
- lib/standard_id/config_schema.rb
Overview
DSL: ‘define { scope :base do field :foo, type: :string, default: “x” end }`. Anonymous-class form keeps both levels in one place; #scope yields a sub-DSL that closes over the parent schema + scope name.
Instance Method Summary collapse
- #field(name, type: :string, default: nil) ⇒ Object
-
#initialize(schema, scope_name = nil) ⇒ DSL
constructor
A new instance of DSL.
- #scope(name, &block) ⇒ Object
Constructor Details
#initialize(schema, scope_name = nil) ⇒ DSL
Returns a new instance of DSL.
93 94 95 96 |
# File 'lib/standard_id/config_schema.rb', line 93 def initialize(schema, scope_name = nil) @schema = schema @scope_name = scope_name end |
Instance Method Details
#field(name, type: :string, default: nil) ⇒ Object
103 104 105 |
# File 'lib/standard_id/config_schema.rb', line 103 def field(name, type: :string, default: nil, **) @schema.add_field(scope: @scope_name, name: name, type: type, default: default) end |