Class: Rack::App::Endpoint::Config
- Inherits:
-
Object
- Object
- Rack::App::Endpoint::Config
- Defined in:
- lib/rack/app/endpoint/config.rb
Instance Method Summary collapse
- #ancestor_apps ⇒ Object
- #app_class ⇒ Object
- #callable ⇒ Object
- #defined_request_path ⇒ Object
- #description ⇒ Object
- #endpoint_specific_middlewares ⇒ Object
- #error_handler ⇒ Object
- #middlewares ⇒ Object
- #payload ⇒ Object
- #payload_builder ⇒ Object
- #payload_parser ⇒ Object
- #request_method ⇒ Object
- #request_path ⇒ Object
- #serializer ⇒ Object
- #serializer_builder ⇒ Object
- #to_hash ⇒ Object
- #type ⇒ Object
Instance Method Details
#ancestor_apps ⇒ Object
30 31 32 |
# File 'lib/rack/app/endpoint/config.rb', line 30 def ancestor_apps [@raw[:ancestors]].flatten.compact end |
#app_class ⇒ Object
34 35 36 |
# File 'lib/rack/app/endpoint/config.rb', line 34 def app_class ancestor_apps.first || raise('missing app class') end |
#callable ⇒ Object
13 14 15 |
# File 'lib/rack/app/endpoint/config.rb', line 13 def callable @raw[:callable] end |
#defined_request_path ⇒ Object
79 80 81 |
# File 'lib/rack/app/endpoint/config.rb', line 79 def defined_request_path Rack::App::Utils.normalize_path(@raw[:defined_request_path] ||= request_path) end |
#description ⇒ Object
83 84 85 86 87 |
# File 'lib/rack/app/endpoint/config.rb', line 83 def description @raw[:route][:description] || @raw[:route][:desc] rescue nil end |
#endpoint_specific_middlewares ⇒ Object
67 68 69 |
# File 'lib/rack/app/endpoint/config.rb', line 67 def endpoint_specific_middlewares @raw[:endpoint_specific_middlewares] ||= [] end |
#error_handler ⇒ Object
63 64 65 |
# File 'lib/rack/app/endpoint/config.rb', line 63 def error_handler @raw[:error_handler] ||= Rack::App::ErrorHandler.new end |
#middlewares ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/rack/app/endpoint/config.rb', line 38 def middlewares mws = [] ancestor_apps.reverse_each do |ancestors_app| mws.push(*ancestors_app.middlewares) end mws.push(*endpoint_specific_middlewares) return mws end |
#payload ⇒ Object
51 52 53 |
# File 'lib/rack/app/endpoint/config.rb', line 51 def payload app_class.__send__(:payload) end |
#payload_builder ⇒ Object
26 27 28 |
# File 'lib/rack/app/endpoint/config.rb', line 26 def payload_builder @raw[:payload].parser_builder end |
#payload_parser ⇒ Object
55 56 57 |
# File 'lib/rack/app/endpoint/config.rb', line 55 def payload_parser payload.parser.to_parser end |
#request_method ⇒ Object
71 72 73 |
# File 'lib/rack/app/endpoint/config.rb', line 71 def request_method @raw[:request_method] || raise('missing config: request_methods') end |
#request_path ⇒ Object
75 76 77 |
# File 'lib/rack/app/endpoint/config.rb', line 75 def request_path Rack::App::Utils.normalize_path(@raw[:request_path] || raise('missing request_path!')) end |
#serializer ⇒ Object
47 48 49 |
# File 'lib/rack/app/endpoint/config.rb', line 47 def serializer serializer_builder.to_serializer end |
#serializer_builder ⇒ Object
59 60 61 |
# File 'lib/rack/app/endpoint/config.rb', line 59 def serializer_builder @raw[:serializer_builder] ||= app_class.__send__(:formats) end |
#to_hash ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/rack/app/endpoint/config.rb', line 4 def to_hash error_handler endpoint_specific_middlewares request_path request_method defined_request_path @raw end |
#type ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rack/app/endpoint/config.rb', line 17 def type case callable when ::Rack::App::Block :endpoint else :application end end |