Module: Restspec::Endpoints::HasSchemas
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/restspec/endpoints/has_schemas.rb
Constant Summary collapse
- DEFAULT_ROLES =
[:response]
- ROLES =
[:response, :payload]
Instance Method Summary collapse
- #add_schema(schema_name, options) ⇒ Object
- #all_schemas ⇒ Object
- #remove_schemas ⇒ Object
- #schema_for(role_name) ⇒ Object
- #schema_roles ⇒ Object
Instance Method Details
#add_schema(schema_name, options) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/restspec/endpoints/has_schemas.rb', line 16 def add_schema(schema_name, ) roles = .delete(:for) || DEFAULT_ROLES roles.each do |role| schema_found = Restspec::SchemaStore.fetch(schema_name) schema_roles[role] = DeepClone.clone(schema_found) schema_roles[role].intention = role schema_roles[role].original_schema = schema_found if .any? schema_roles[role].extend_with() end end end |
#all_schemas ⇒ Object
32 33 34 |
# File 'lib/restspec/endpoints/has_schemas.rb', line 32 def all_schemas schema_roles.values end |
#remove_schemas ⇒ Object
36 37 38 |
# File 'lib/restspec/endpoints/has_schemas.rb', line 36 def remove_schemas schema_roles.clear end |
#schema_for(role_name) ⇒ Object
40 41 42 |
# File 'lib/restspec/endpoints/has_schemas.rb', line 40 def schema_for(role_name) schema_roles[role_name] end |
#schema_roles ⇒ Object
12 13 14 |
# File 'lib/restspec/endpoints/has_schemas.rb', line 12 def schema_roles @schema_roles ||= {} end |