Class: Restspec::Schema::DSL
- Inherits:
-
Object
- Object
- Restspec::Schema::DSL
- Defined in:
- lib/restspec/schema/dsl.rb
Overview
The Schema DSL is what should be used inside the schemas.rb
file.
This class is related to the top-level namespace of the DSL.
Instance Method Summary collapse
-
#initialize ⇒ DSL
constructor
A new instance of DSL.
-
#mixin(name, &definition) ⇒ Object
Generates a set of calls that can be executed in many schemas with SingleSchemaDSL#include_attributes.
-
#schema(name, options = {}, &definition) ⇒ Object
Generates a schema and sends the schema to an SingleSchemaDSL instance for further definitions.
Constructor Details
#initialize ⇒ DSL
Returns a new instance of DSL.
6 7 8 |
# File 'lib/restspec/schema/dsl.rb', line 6 def initialize self.mixins = {} end |
Instance Method Details
#mixin(name, &definition) ⇒ Object
Generates a set of calls that can be executed in many schemas with SingleSchemaDSL#include_attributes.
They are useful to share attributes.
52 53 54 |
# File 'lib/restspec/schema/dsl.rb', line 52 def mixin(name, &definition) mixins[name] = definition end |
#schema(name, options = {}, &definition) ⇒ Object
Generates a schema and sends the schema to an SingleSchemaDSL instance for further definitions.
23 24 25 26 27 |
# File 'lib/restspec/schema/dsl.rb', line 23 def schema(name, = {}, &definition) dsl = SingleSchemaDSL.new(name, , mixins) dsl.instance_eval(&definition) Restspec::SchemaStore.store(dsl.schema) end |