Class: Rack::App::Endpoint::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/app/endpoint/config.rb

Instance Method Summary collapse

Instance Method Details

#ancestor_appsObject



30
31
32
# File 'lib/rack/app/endpoint/config.rb', line 30

def ancestor_apps
  [@raw[:ancestors]].flatten.compact
end

#app_classObject



34
35
36
# File 'lib/rack/app/endpoint/config.rb', line 34

def app_class
  ancestor_apps.first || raise('missing app class')
end

#callableObject



13
14
15
# File 'lib/rack/app/endpoint/config.rb', line 13

def callable
  @raw[:callable]
end

#defined_request_pathObject



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

#descriptionObject



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_middlewaresObject



67
68
69
# File 'lib/rack/app/endpoint/config.rb', line 67

def endpoint_specific_middlewares
  @raw[:endpoint_specific_middlewares] ||= []
end

#error_handlerObject



63
64
65
# File 'lib/rack/app/endpoint/config.rb', line 63

def error_handler
  @raw[:error_handler] ||= Rack::App::ErrorHandler.new
end

#middlewaresObject



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

#payloadObject



51
52
53
# File 'lib/rack/app/endpoint/config.rb', line 51

def payload
  app_class.__send__(:payload)
end

#payload_builderObject



26
27
28
# File 'lib/rack/app/endpoint/config.rb', line 26

def payload_builder
  @raw[:payload].parser_builder
end

#payload_parserObject



55
56
57
# File 'lib/rack/app/endpoint/config.rb', line 55

def payload_parser
  payload.parser.to_parser
end

#request_methodObject



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_pathObject



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

#serializerObject



47
48
49
# File 'lib/rack/app/endpoint/config.rb', line 47

def serializer
  serializer_builder.to_serializer
end

#serializer_builderObject



59
60
61
# File 'lib/rack/app/endpoint/config.rb', line 59

def serializer_builder
  @raw[:serializer_builder] ||= app_class.__send__(:formats)
end

#to_hashObject



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

#typeObject



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