Class: Restspec::Schema::SingleSchemaDSL
- Inherits:
-
Object
- Object
- Restspec::Schema::SingleSchemaDSL
- Defined in:
- lib/restspec/schema/dsl.rb
Instance Attribute Summary collapse
-
#mixins ⇒ Object
readonly
Returns the value of attribute mixins.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
- #attribute(name, type, options = {}) ⇒ Object
- #include_attributes(name) ⇒ Object
-
#initialize(name, mixins = {}) ⇒ SingleSchemaDSL
constructor
A new instance of SingleSchemaDSL.
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
#mixins ⇒ Object
Returns the value of attribute mixins.
23 24 25 |
# File 'lib/restspec/schema/dsl.rb', line 23 def mixins @mixins end |
#schema ⇒ Object
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, = {}) new_attribute = Attribute.new(name, type, ) 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 |