Class: Evil::Client::Schema Abstract
- Inherits:
-
Object
- Object
- Evil::Client::Schema
- Defined in:
- lib/evil/client/schema.rb
Overview
Base class for mutable containers of client-specific definitions of nested scopes and operations along with a corresponding [#settings] class subclassing [Evil::Client::Settings]
Every concrete container defines its only DSL for scope/operation definitions.
Direct Known Subclasses
Defined Under Namespace
Instance Attribute Summary collapse
-
#client ⇒ Evil::Client
readonly
Back reference to client the schema belongs to.
-
#name ⇒ String
readonly
The name of current schema which is unique for the existing [#parent], or equals to client class name without any [#parent] (root scope name).
-
#parent ⇒ Evil::Client::Schema::Scope?
readonly
Scope schema the operation belongs to.
Instance Method Summary collapse
-
#let(key, &block) ⇒ self
Adds a memoized method to the [#settings] class.
-
#option(key, type = nil, **opts) ⇒ self
Adds an option to the [#settings] class.
-
#settings ⇒ Class
The settings class inherited from the [#parent]‘s one.
-
#to_s ⇒ String
(also: #to_str, #inspect)
The human-friendly representation of the schema.
-
#validate(*_args, &block) ⇒ self
Adds validator to the [#settings] class.
Instance Attribute Details
#client ⇒ Evil::Client (readonly)
Back reference to client the schema belongs to
38 39 40 |
# File 'lib/evil/client/schema.rb', line 38 def client @client end |
#name ⇒ String (readonly)
The name of current schema which is unique for the existing [#parent], or equals to client class name without any [#parent] (root scope name).
23 24 25 |
# File 'lib/evil/client/schema.rb', line 23 def name @name end |
#parent ⇒ Evil::Client::Schema::Scope? (readonly)
Scope schema the operation belongs to
Only the root schema has no parents. Its definitions are shared by all operations
32 33 34 |
# File 'lib/evil/client/schema.rb', line 32 def parent @parent end |
Instance Method Details
#let(key, &block) ⇒ self
Adds a memoized method to the [#settings] class
77 78 79 80 |
# File 'lib/evil/client/schema.rb', line 77 def let(key, &block) settings.let(key, &block) self end |
#option(key, type = nil, **opts) ⇒ self
Adds an option to the [#settings] class
67 68 69 70 |
# File 'lib/evil/client/schema.rb', line 67 def option(key, type = nil, **opts) settings.option(key, type, **opts) self end |
#settings ⇒ Class
The settings class inherited from the [#parent]‘s one
57 58 59 |
# File 'lib/evil/client/schema.rb', line 57 def settings @settings ||= (parent&.settings || Settings).for(self) end |
#to_s ⇒ String Also known as: to_str, inspect
The human-friendly representation of the schema
47 48 49 |
# File 'lib/evil/client/schema.rb', line 47 def to_s [parent, name].compact.join(".") end |
#validate(*_args, &block) ⇒ self
Adds validator to the [#settings] class
87 88 89 90 |
# File 'lib/evil/client/schema.rb', line 87 def validate(*_args, &block) settings.validate(&block) self end |