Class: Opushon::Option Private
- Inherits:
-
Object
- Object
- Opushon::Option
- Defined in:
- lib/opushon/option.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #description ⇒ Object readonly private
- #request ⇒ Object readonly private
- #response ⇒ Object readonly private
- #title ⇒ Object readonly private
Class Method Summary collapse
- .load(hash) ⇒ Object private
Instance Method Summary collapse
-
#initialize(title: '', description: '', request: {}, response: {}) ⇒ Option
constructor
private
A new instance of Option.
- #to_h ⇒ Object private
Constructor Details
#initialize(title: '', description: '', request: {}, response: {}) ⇒ Option
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Option.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/opushon/option.rb', line 28 def initialize(title: '', description: '', request: {}, response: {}) raise ArgumentError, "title #{title.inspect}" unless title.is_a?(String) raise ArgumentError, "description #{description.inspect}" unless description.is_a?(String) raise ArgumentError, "request #{request.inspect}" unless request.is_a?(Hash) raise ArgumentError, "response #{response.inspect}" unless response.is_a?(Hash) @title = title @description = description @request = Request.load(request) @response = Response.load(response) end |
Instance Attribute Details
#description ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/opushon/option.rb', line 26 def description @description end |
#request ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/opushon/option.rb', line 26 def request @request end |
#response ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/opushon/option.rb', line 26 def response @response end |
#title ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/opushon/option.rb', line 26 def title @title end |
Class Method Details
.load(hash) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/opushon/option.rb', line 8 def self.load(hash) raise ArgumentError, "hash #{hash.inspect}" unless hash.is_a?(Hash) title = hash.fetch('title', nil) description = hash.fetch('description', nil) request = hash.fetch('request', nil) response = hash.fetch('response', nil) hash = { title: title, description: description, request: request, response: response }.compact new(**hash) end |
Instance Method Details
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 43 44 45 46 47 |
# File 'lib/opushon/option.rb', line 40 def to_h { title: title, description: description, request: request.to_h, response: response.to_h } end |