class Atum::Core::Schema::ApiSchema
Attributes
schema[R]
Public Class Methods
new(schema)
click to toggle source
# File lib/atum/core/schema/api_schema.rb, line 7 def initialize(schema) @schema = schema end
Public Instance Methods
description()
click to toggle source
Description of the API
# File lib/atum/core/schema/api_schema.rb, line 12 def description @schema['description'] end
inspect()
click to toggle source
Get a simple human-readable representation of this client instance.
# File lib/atum/core/schema/api_schema.rb, line 35 def inspect "#<Atum::ApiSchema description=\"#{description}\">" end
Also aliased as: to_s
lookup_path(*path)
click to toggle source
Lookup a path in this schema.
@param path [Array<String>] Array of keys, one for each to look up in
the schema
@return [Object] Value at the specifed path in this schema.
# File lib/atum/core/schema/api_schema.rb, line 46 def lookup_path(*path) path.reduce(@schema) { |a, e| a[e] } end
resource_schema_for(name)
click to toggle source
Get the schema for a resource.
@param name [String] The name of the resource. @raise [SchemaError] Raised if an unknown resource name is provided. @return ResourceSchema
The resource schema for resource called name
# File lib/atum/core/schema/api_schema.rb, line 21 def resource_schema_for(name) unless resource_schema_hash.key?(name) raise SchemaError, "Unknown resource '#{name}'." end resource_schema_hash[name] end
resource_schemas()
click to toggle source
@return [Array<ResourceSchema>] The resource schemata in this API.
# File lib/atum/core/schema/api_schema.rb, line 30 def resource_schemas resource_schema_hash.values end
Private Instance Methods
resource_schema_hash()
click to toggle source
# File lib/atum/core/schema/api_schema.rb, line 52 def resource_schema_hash @resource_schema_hash ||= @schema['definitions'].each_with_object({}) do |(key, value), memo| memo[key] = ResourceSchema.new(self, value, key) end end