Class: Restspec::Schema::SchemaExample
- Inherits:
-
Object
- Object
- Restspec::Schema::SchemaExample
- Defined in:
- lib/restspec/schema/schema_example.rb
Instance Attribute Summary collapse
-
#extensions ⇒ Object
Returns the value of attribute extensions.
-
#schema ⇒ Object
Returns the value of attribute schema.
Instance Method Summary collapse
-
#initialize(schema, extensions = {}) ⇒ SchemaExample
constructor
A new instance of SchemaExample.
- #value ⇒ Object
Constructor Details
#initialize(schema, extensions = {}) ⇒ SchemaExample
Returns a new instance of SchemaExample.
6 7 8 9 |
# File 'lib/restspec/schema/schema_example.rb', line 6 def initialize(schema, extensions = {}) self.schema = schema self.extensions = extensions end |
Instance Attribute Details
#extensions ⇒ Object
Returns the value of attribute extensions.
4 5 6 |
# File 'lib/restspec/schema/schema_example.rb', line 4 def extensions @extensions end |
#schema ⇒ Object
Returns the value of attribute schema.
4 5 6 |
# File 'lib/restspec/schema/schema_example.rb', line 4 def schema @schema end |
Instance Method Details
#value ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/restspec/schema/schema_example.rb', line 11 def value attributes.inject({}) do |sample, (_, attribute)| if attribute.can_generate_examples? sample.merge(attribute.name => AttributeExample.new(attribute).value) else sample end end.merge(extensions) end |