module Restspec::Endpoints::HasSchemas

Constants

DEFAULT_ROLES
ROLES

Public Instance Methods

add_schema(schema_name, options) click to toggle source
# File lib/restspec/endpoints/has_schemas.rb, line 16
def add_schema(schema_name, options)
  roles = options.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 options.any?
      schema_roles[role].extend_with(options)
    end
  end
end
all_schemas() click to toggle source
# File lib/restspec/endpoints/has_schemas.rb, line 32
def all_schemas
  schema_roles.values
end
remove_schemas() click to toggle source
# File lib/restspec/endpoints/has_schemas.rb, line 36
def remove_schemas
  schema_roles.clear
end
schema_for(role_name) click to toggle source
# File lib/restspec/endpoints/has_schemas.rb, line 40
def schema_for(role_name)
  schema_roles[role_name]
end
schema_roles() click to toggle source
# File lib/restspec/endpoints/has_schemas.rb, line 12
def schema_roles
  @schema_roles ||= {}
end