Class: DryOpenApi::Responses
- Inherits:
-
Object
- Object
- DryOpenApi::Responses
- Extended by:
- Dry::Initializer, Forwardable
- Includes:
- EquatableAsContent
- Defined in:
- lib/dry_open_api/responses.rb
Instance Attribute Summary collapse
-
#default ⇒ Object
Returns the value of attribute default.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(default: nil, **responses_hash) ⇒ Responses
constructor
A new instance of Responses.
- #serializable_hash ⇒ Object
Methods included from EquatableAsContent
Constructor Details
#initialize(default: nil, **responses_hash) ⇒ Responses
Returns a new instance of Responses.
11 12 13 14 |
# File 'lib/dry_open_api/responses.rb', line 11 def initialize(default: nil, **responses_hash) self.default = default self.responses_hash = responses_hash.with_indifferent_access end |
Instance Attribute Details
#default ⇒ Object
Returns the value of attribute default.
9 10 11 |
# File 'lib/dry_open_api/responses.rb', line 9 def default @default end |
Class Method Details
.load(hash) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/dry_open_api/responses.rb', line 26 def self.load(hash) return unless hash hash = hash.map { |k, v| [k.to_s.to_sym, Response.load(v)] }.to_h new(**hash) end |
Instance Method Details
#serializable_hash ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/dry_open_api/responses.rb', line 18 def serializable_hash { 'default' => default&.serializable_hash } .merge(responses_hash.map { |k, v| [k.to_s, v.serializable_hash] }.to_h) .compact end |