Class: Sparrow::Configuration
- Inherits:
-
Object
- Object
- Sparrow::Configuration
- Defined in:
- lib/sparrow/configuration.rb
Overview
Middleware configuration store see https://github.com/GateprotectGmbH/sparrow#configuration
Instance Attribute Summary collapse
-
#allowed_accepts ⇒ Object
Returns the value of attribute allowed_accepts.
-
#allowed_content_types ⇒ Object
Returns the value of attribute allowed_content_types.
-
#camelize_ignore_uppercase_keys ⇒ Object
Returns the value of attribute camelize_ignore_uppercase_keys.
-
#camelize_strategy ⇒ Object
Returns the value of attribute camelize_strategy.
-
#default_json_request_key_transformation_strategy ⇒ Object
Returns the value of attribute default_json_request_key_transformation_strategy.
-
#default_json_response_key_transformation_strategy ⇒ Object
Returns the value of attribute default_json_response_key_transformation_strategy.
-
#enable_logging ⇒ Object
Returns the value of attribute enable_logging.
-
#excluded_routes ⇒ Object
Returns the value of attribute excluded_routes.
-
#ignored_response_codes ⇒ Object
Returns the value of attribute ignored_response_codes.
-
#json_request_format_header ⇒ Object
Returns the value of attribute json_request_format_header.
-
#json_response_format_header ⇒ Object
Returns the value of attribute json_response_format_header.
Instance Method Summary collapse
- #active_support_legacy_version ⇒ Object
-
#default_json_key_transformation_strategy(type) ⇒ String
the default json_key_transformation_strategy option for the given http message type.
-
#initialize ⇒ Configuration
constructor
Initializes a new Configuration with default parameters.
-
#json_format_header(type) ⇒ String
The configuration value for the json_format_header for the given http message type.
Constructor Details
#initialize ⇒ Configuration
Initializes a new Configuration with default parameters
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sparrow/configuration.rb', line 19 def initialize @enable_logging = false @json_request_format_header = 'request-json-format' @json_response_format_header = 'response-json-format' @excluded_routes = [] @default_json_request_key_transformation_strategy = :underscore @default_json_response_key_transformation_strategy = :camelize @camelize_ignore_uppercase_keys = true @allowed_content_types = %w[ application/json application/x-www-form-urlencoded text/x-json ] @allowed_accepts = @allowed_content_types + [nil] @ignored_response_codes = [404] + (500..511).to_a @camelize_strategy = :lower end |
Instance Attribute Details
#allowed_accepts ⇒ Object
Returns the value of attribute allowed_accepts.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def allowed_accepts @allowed_accepts end |
#allowed_content_types ⇒ Object
Returns the value of attribute allowed_content_types.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def allowed_content_types @allowed_content_types end |
#camelize_ignore_uppercase_keys ⇒ Object
Returns the value of attribute camelize_ignore_uppercase_keys.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def camelize_ignore_uppercase_keys @camelize_ignore_uppercase_keys end |
#camelize_strategy ⇒ Object
Returns the value of attribute camelize_strategy.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def camelize_strategy @camelize_strategy end |
#default_json_request_key_transformation_strategy ⇒ Object
Returns the value of attribute default_json_request_key_transformation_strategy.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def default_json_request_key_transformation_strategy @default_json_request_key_transformation_strategy end |
#default_json_response_key_transformation_strategy ⇒ Object
Returns the value of attribute default_json_response_key_transformation_strategy.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def default_json_response_key_transformation_strategy @default_json_response_key_transformation_strategy end |
#enable_logging ⇒ Object
Returns the value of attribute enable_logging.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def enable_logging @enable_logging end |
#excluded_routes ⇒ Object
Returns the value of attribute excluded_routes.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def excluded_routes @excluded_routes end |
#ignored_response_codes ⇒ Object
Returns the value of attribute ignored_response_codes.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def ignored_response_codes @ignored_response_codes end |
#json_request_format_header ⇒ Object
Returns the value of attribute json_request_format_header.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def json_request_format_header @json_request_format_header end |
#json_response_format_header ⇒ Object
Returns the value of attribute json_response_format_header.
5 6 7 |
# File 'lib/sparrow/configuration.rb', line 5 def json_response_format_header @json_response_format_header end |
Instance Method Details
#active_support_legacy_version ⇒ Object
38 39 40 |
# File 'lib/sparrow/configuration.rb', line 38 def active_support_legacy_version /3\.\d+\.\d+/ end |
#default_json_key_transformation_strategy(type) ⇒ String
the default json_key_transformation_strategy option for the given http message type
57 58 59 |
# File 'lib/sparrow/configuration.rb', line 57 def default_json_key_transformation_strategy(type) public_send("default_json_#{type}_key_transformation_strategy") end |
#json_format_header(type) ⇒ String
Returns the configuration value for the json_format_header for the given http message type.
47 48 49 |
# File 'lib/sparrow/configuration.rb', line 47 def json_format_header(type) public_send("json_#{type}_format_header") end |