Class: OpenApi::DSL::CallbackObj
- Inherits:
-
Hash
- Object
- Hash
- OpenApi::DSL::CallbackObj
- Includes:
- Helpers
- Defined in:
- lib/oas_objs/callback_obj.rb
Overview
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#callback_url ⇒ Object
Returns the value of attribute callback_url.
-
#event_name ⇒ Object
Returns the value of attribute event_name.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
Instance Method Summary collapse
-
#initialize(event_name, http_method, callback_url, &block) ⇒ CallbackObj
constructor
A new instance of CallbackObj.
- #process ⇒ Object
- #processed_url ⇒ Object
Methods included from Helpers
#_combined_schema, #arrow_writing_support, #process_schema_input
Constructor Details
#initialize(event_name, http_method, callback_url, &block) ⇒ CallbackObj
Returns a new instance of CallbackObj.
13 14 15 16 17 18 |
# File 'lib/oas_objs/callback_obj.rb', line 13 def initialize(event_name, http_method, callback_url, &block) self.event_name = event_name self.http_method = http_method self.callback_url = callback_url self.block = block end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
11 12 13 |
# File 'lib/oas_objs/callback_obj.rb', line 11 def block @block end |
#callback_url ⇒ Object
Returns the value of attribute callback_url.
11 12 13 |
# File 'lib/oas_objs/callback_obj.rb', line 11 def callback_url @callback_url end |
#event_name ⇒ Object
Returns the value of attribute event_name.
11 12 13 |
# File 'lib/oas_objs/callback_obj.rb', line 11 def event_name @event_name end |
#http_method ⇒ Object
Returns the value of attribute http_method.
11 12 13 |
# File 'lib/oas_objs/callback_obj.rb', line 11 def http_method @http_method end |
Instance Method Details
#process ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/oas_objs/callback_obj.rb', line 20 def process { event_name => { processed_url => { http_method.downcase.to_sym => Api.new.run_dsl(&(self.block || -> { })) } } } end |
#processed_url ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/oas_objs/callback_obj.rb', line 30 def processed_url callback_url.gsub(/{[^{}]*}/) do |exp| key_location, key_name = exp[1..-2].split connector = key_location == 'body' ? '#/' : '.' key_location = '$request.' + key_location ['{', key_location, connector, key_name, '}'].join end end |