Class: Restspec::Schema::DSL

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDSL

Returns a new instance of DSL.



7
8
9
# File 'lib/restspec/schema/dsl.rb', line 7

def initialize
  self.mixins = {}
end

Instance Attribute Details

#mixinsObject

Returns the value of attribute mixins.



5
6
7
# File 'lib/restspec/schema/dsl.rb', line 5

def mixins
  @mixins
end

#schemasObject (readonly)

Returns the value of attribute schemas.



4
5
6
# File 'lib/restspec/schema/dsl.rb', line 4

def schemas
  @schemas
end

Instance Method Details

#mixin(name, &definition) ⇒ Object



17
18
19
# File 'lib/restspec/schema/dsl.rb', line 17

def mixin(name, &definition)
  mixins[name] = definition
end

#schema(name, &definition) ⇒ Object



11
12
13
14
15
# File 'lib/restspec/schema/dsl.rb', line 11

def schema(name, &definition)
  dsl = SingleSchemaDSL.new(name, mixins)
  dsl.instance_eval(&definition)
  Restspec::SchemaStore.store(dsl.schema)
end