Class: GrapeSwagger::RequestParamParserRegistry

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/grape-swagger/request_param_parser_registry.rb

Constant Summary collapse

DEFAULT_PARSERS =
[
  GrapeSwagger::RequestParamParsers::Headers,
  GrapeSwagger::RequestParamParsers::Route,
  GrapeSwagger::RequestParamParsers::Body
].freeze

Instance Method Summary collapse

Constructor Details

#initializeRequestParamParserRegistry

Returns a new instance of RequestParamParserRegistry.



17
18
19
# File 'lib/grape-swagger/request_param_parser_registry.rb', line 17

def initialize
  @parsers = DEFAULT_PARSERS.dup
end

Instance Method Details

#eachObject



38
39
40
# File 'lib/grape-swagger/request_param_parser_registry.rb', line 38

def each(&)
  @parsers.each(&)
end

#insert_after(after_klass, klass) ⇒ Object



32
33
34
35
36
# File 'lib/grape-swagger/request_param_parser_registry.rb', line 32

def insert_after(after_klass, klass)
  remove_parser(klass)
  insert_at = @parsers.index(after_klass)
  @parsers.insert(insert_at ? insert_at + 1 : @parsers.size, klass)
end

#insert_before(before_klass, klass) ⇒ Object



26
27
28
29
30
# File 'lib/grape-swagger/request_param_parser_registry.rb', line 26

def insert_before(before_klass, klass)
  remove_parser(klass)
  insert_at = @parsers.index(before_klass) || @parsers.size
  @parsers.insert(insert_at, klass)
end

#register(klass) ⇒ Object



21
22
23
24
# File 'lib/grape-swagger/request_param_parser_registry.rb', line 21

def register(klass)
  remove_parser(klass)
  @parsers << klass
end