Class: Restspec::Schema::SingleSchemaDSL

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, mixins = {}) ⇒ SingleSchemaDSL

Returns a new instance of SingleSchemaDSL.



25
26
27
28
# File 'lib/restspec/schema/dsl.rb', line 25

def initialize(name, mixins = {})
  self.schema = Schema.new(name)
  self.mixins = mixins
end

Instance Attribute Details

#mixinsObject

Returns the value of attribute mixins.



23
24
25
# File 'lib/restspec/schema/dsl.rb', line 23

def mixins
  @mixins
end

#schemaObject

Returns the value of attribute schema.



23
24
25
# File 'lib/restspec/schema/dsl.rb', line 23

def schema
  @schema
end

Instance Method Details

#attribute(name, type, options = {}) ⇒ Object



30
31
32
33
# File 'lib/restspec/schema/dsl.rb', line 30

def attribute(name, type, options = {})
  new_attribute = Attribute.new(name, type, options)
  schema.attributes[name.to_s] = new_attribute
end

#include_attributes(name) ⇒ Object



35
36
37
# File 'lib/restspec/schema/dsl.rb', line 35

def include_attributes(name)
  self.instance_eval &mixins.fetch(name)
end