Class: GrapeSwagger::RequestParamParserRegistry
- Inherits:
-
Object
- Object
- GrapeSwagger::RequestParamParserRegistry
- 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
- #each ⇒ Object
-
#initialize ⇒ RequestParamParserRegistry
constructor
A new instance of RequestParamParserRegistry.
- #insert_after(after_klass, klass) ⇒ Object
- #insert_before(before_klass, klass) ⇒ Object
- #register(klass) ⇒ Object
Constructor Details
#initialize ⇒ RequestParamParserRegistry
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
#each ⇒ Object
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 |