Class: Evil::Client::Schema::Scope
- Inherits:
-
Operation
- Object
- Evil::Client::Schema
- Operation
- Evil::Client::Schema::Scope
- Defined in:
- lib/evil/client/schema/scope.rb
Overview
Mutable container of definitions for sub-scopes and operations with DSL to configure those definitions.
Instance Attribute Summary
Attributes inherited from Evil::Client::Schema
Instance Method Summary collapse
-
#leaf? ⇒ false
Tells that this is a schema for a scope (not the final operation).
-
#operation(name, &block) ⇒ self
Creates or updates operation definition.
-
#operations ⇒ Hash<[Symbol, nil], Class>
The collection of named operation schemas.
-
#scope(name, &block) ⇒ self
Creates or updates sub-scope definition.
-
#scopes ⇒ Hash<Symbol, Class>
The collection of named sub-scope schemas.
Methods inherited from Operation
#body, #definitions, #format, #headers, #http_method, #middleware, #path, #query, #response, #security
Methods inherited from Evil::Client::Schema
#let, #option, #settings, #to_s, #validate
Instance Method Details
#leaf? ⇒ false
Tells that this is a schema for a scope (not the final operation)
13 14 15 |
# File 'lib/evil/client/schema/scope.rb', line 13 def leaf? false end |
#operation(name, &block) ⇒ self
Creates or updates operation definition
55 56 57 58 59 60 61 |
# File 'lib/evil/client/schema/scope.rb', line 55 def operation(name, &block) key = NameError.check!(name) TypeError.check! self, key, :operation @__children__[key] ||= self.class.superclass.new(self, key) @__children__[key].instance_exec(&block) self end |
#operations ⇒ Hash<[Symbol, nil], Class>
The collection of named operation schemas
31 32 33 |
# File 'lib/evil/client/schema/scope.rb', line 31 def operations @__children__.select { |_, child| child.leaf? } end |
#scope(name, &block) ⇒ self
Creates or updates sub-scope definition
41 42 43 44 45 46 47 |
# File 'lib/evil/client/schema/scope.rb', line 41 def scope(name, &block) key = NameError.check!(name) TypeError.check! self, key, :scope @__children__[key] ||= self.class.new(self, key) @__children__[key].instance_exec(&block) self end |
#scopes ⇒ Hash<Symbol, Class>
The collection of named sub-scope schemas
Every sub-scope schema refers to the current one as a [#parent]
23 24 25 |
# File 'lib/evil/client/schema/scope.rb', line 23 def scopes @__children__.reject { |_, child| child.leaf? } end |