Class: Jsapi::Meta::Base::Reference
- Defined in:
- lib/jsapi/meta/base/reference.rb
Overview
The base reference class.
Direct Known Subclasses
Callback::Reference, Example::Reference, Header::Reference, Link::Reference, Parameter::Reference, RequestBody::Reference, Response::Reference, Schema::Reference
Constant Summary
Constants included from Attributes
Attributes::DEFAULT_ARRAY, Attributes::DEFAULT_HASH
Class Method Summary collapse
-
.component_type ⇒ Object
Derrives the component type from the inner most module name.
Instance Method Summary collapse
-
#ref ⇒ Object
:attr: ref The name of the referred object.
-
#reference? ⇒ Boolean
Returns true.
-
#resolve(definitions) ⇒ Object
Resolves
ref
by looking up the object with that name indefinitions
.
Methods inherited from Model
#initialize, #inspect, #merge!
Methods included from Attributes
Constructor Details
This class inherits a constructor from Jsapi::Meta::Base::Model
Class Method Details
.component_type ⇒ Object
Derrives the component type from the inner most module name.
14 15 16 |
# File 'lib/jsapi/meta/base/reference.rb', line 14 def self.component_type @component_type ||= name.split('::')[-2].underscore end |
Instance Method Details
#ref ⇒ Object
:attr: ref The name of the referred object.
11 |
# File 'lib/jsapi/meta/base/reference.rb', line 11 attribute :ref, String |
#reference? ⇒ Boolean
Returns true.
19 20 21 |
# File 'lib/jsapi/meta/base/reference.rb', line 19 def reference? true end |
#resolve(definitions) ⇒ Object
Resolves ref
by looking up the object with that name in definitions
.
Raises a ReferenceError if ref
could not be resolved.
26 27 28 29 30 31 |
# File 'lib/jsapi/meta/base/reference.rb', line 26 def resolve(definitions) object = definitions.send("find_#{self.class.component_type}", ref) raise ReferenceError, ref if object.nil? object.resolve(definitions) end |