Class: Jsapi::Meta::Base::Model
- Inherits:
-
Object
- Object
- Jsapi::Meta::Base::Model
- Extended by:
- Attributes
- Defined in:
- lib/jsapi/meta/base/model.rb
Overview
The base meta model class.
Direct Known Subclasses
Reference, Callback::Model, Contact, Defaults, Definitions, Example::Model, ExternalDocumentation, Header::Model, Info, License, Link::Model, OAuthFlow, OAuthFlow::Scope, Operation, Parameter::Model, Property, RequestBody::Model, RescueHandler, Response::Model, Schema::AdditionalProperties, Schema::Base, Schema::Discriminator, SecurityRequirement, SecurityRequirement::Scheme, SecurityScheme::Base, Server, ServerVariable, Tag
Constant Summary
Constants included from Attributes
Attributes::DEFAULT_ARRAY, Attributes::DEFAULT_HASH
Instance Method Summary collapse
-
#initialize(keywords = {}) ⇒ Model
constructor
Creates a new meta model.
-
#inspect(*attributes) ⇒ Object
:nodoc:.
-
#merge!(keywords = {}) ⇒ Object
Merges
keywords
into the model. -
#reference? ⇒ Boolean
Returns false.
-
#resolve ⇒ Object
Returns itself.
Methods included from Attributes
Constructor Details
#initialize(keywords = {}) ⇒ Model
Creates a new meta model.
Raises an ArgumentError
if at least one keyword is not supported.
13 14 15 |
# File 'lib/jsapi/meta/base/model.rb', line 13 def initialize(keywords = {}) merge!(keywords) end |
Instance Method Details
#inspect(*attributes) ⇒ Object
:nodoc:
17 18 19 20 21 22 23 24 25 |
# File 'lib/jsapi/meta/base/model.rb', line 17 def inspect(*attributes) # :nodoc: klass = self.class attribute_names = klass.attribute_names attribute_names = attributes & attribute_names if attributes.any? "#<#{klass.name} #{ attribute_names.map { |name| "#{name}: #{send(name).inspect}" }.join(', ') }>" end |
#merge!(keywords = {}) ⇒ Object
Merges keywords
into the model.
Raises an ArgumentError
if at least one keyword is not supported.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jsapi/meta/base/model.rb', line 30 def merge!(keywords = {}) keywords.each do |key, value| if respond_to?(method = "#{key}=") public_send(method, value) else raise ArgumentError, "unsupported keyword: #{key}" end end self end |
#reference? ⇒ Boolean
Returns false.
42 43 44 |
# File 'lib/jsapi/meta/base/model.rb', line 42 def reference? false end |
#resolve ⇒ Object
Returns itself.
47 48 49 |
# File 'lib/jsapi/meta/base/model.rb', line 47 def resolve(*) self end |