Class: Atum::Core::Schema::ApiSchema
- Inherits:
-
Object
- Object
- Atum::Core::Schema::ApiSchema
- Defined in:
- lib/atum/core/schema/api_schema.rb
Instance Attribute Summary collapse
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Instance Method Summary collapse
-
#description ⇒ Object
Description of the API.
-
#initialize(schema) ⇒ ApiSchema
constructor
A new instance of ApiSchema.
-
#inspect ⇒ Object
(also: #to_s)
Get a simple human-readable representation of this client instance.
-
#lookup_path(*path) ⇒ Object
Lookup a path in this schema.
-
#resource_schema_for(name) ⇒ Object
Get the schema for a resource.
-
#resource_schemas ⇒ Array<ResourceSchema>
The resource schemata in this API.
Constructor Details
#initialize(schema) ⇒ ApiSchema
Returns a new instance of ApiSchema.
7 8 9 |
# File 'lib/atum/core/schema/api_schema.rb', line 7 def initialize(schema) @schema = schema end |
Instance Attribute Details
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
5 6 7 |
# File 'lib/atum/core/schema/api_schema.rb', line 5 def schema @schema end |
Instance Method Details
#description ⇒ Object
Description of the API
12 13 14 |
# File 'lib/atum/core/schema/api_schema.rb', line 12 def description @schema['description'] end |
#inspect ⇒ Object Also known as: to_s
Get a simple human-readable representation of this client instance.
35 36 37 |
# File 'lib/atum/core/schema/api_schema.rb', line 35 def inspect "#<Atum::ApiSchema description=\"#{description}\">" end |
#lookup_path(*path) ⇒ Object
Lookup a path in this schema.
46 47 48 |
# 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) ⇒ Object
Get the schema for a resource.
21 22 23 24 25 26 27 |
# 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 ⇒ Array<ResourceSchema>
Returns The resource schemata in this API.
30 31 32 |
# File 'lib/atum/core/schema/api_schema.rb', line 30 def resource_schemas resource_schema_hash.values end |