Class: Jsapi::Meta::BaseReference
- Defined in:
- lib/jsapi/meta/base_reference.rb
Direct Known Subclasses
Example::Reference, OpenAPI::Callback::Reference, OpenAPI::Link::Reference, Parameter::Reference, RequestBody::Reference, Response::Reference, Schema::Reference
Class Method Summary collapse
-
.lookup_method_name ⇒ Object
Returns the name of the method to be invoked to look up the referred object in a Definitions instance.
Instance Method Summary collapse
-
#ref ⇒ Object
:attr: ref The name of the referred object.
-
#reference? ⇒ Boolean
:nodoc:.
-
#resolve(definitions) ⇒ Object
Resolves
ref
by looking up the object with that name indefinitions
.
Methods inherited from Base
Methods included from Attributes::ClassMethods
Constructor Details
This class inherits a constructor from Jsapi::Meta::Base
Class Method Details
.lookup_method_name ⇒ Object
Returns the name of the method to be invoked to look up the referred object in a Definitions instance.
13 14 15 16 |
# File 'lib/jsapi/meta/base_reference.rb', line 13 def self.lookup_method_name @lookup_method_name ||= name.delete_suffix('::Reference').demodulize.underscore end |
Instance Method Details
#ref ⇒ Object
:attr: ref The name of the referred object.
9 |
# File 'lib/jsapi/meta/base_reference.rb', line 9 attribute :ref, String |
#reference? ⇒ Boolean
:nodoc:
18 19 20 |
# File 'lib/jsapi/meta/base_reference.rb', line 18 def reference? # :nodoc: 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.
25 26 27 28 29 30 |
# File 'lib/jsapi/meta/base_reference.rb', line 25 def resolve(definitions) object = definitions.send(self.class.lookup_method_name, ref) raise ReferenceError, ref if object.nil? object.resolve(definitions) end |