Class: Praxis::ActionDefinition::HeadersDSLCompiler
- Inherits:
-
Attributor::DSLCompiler
- Object
- Attributor::DSLCompiler
- Praxis::ActionDefinition::HeadersDSLCompiler
- Defined in:
- lib/praxis/action_definition/headers_dsl_compiler.rb
Instance Method Summary collapse
-
#attribute(name, attr_type = nil, **opts, &block) ⇒ Object
Override the attribute to really call “key” in the hash (for temporary backwards compat).
-
#header(name, val = nil, **options) ⇒ Object
it allows to define expectations on incoming headers.
Instance Method Details
#attribute(name, attr_type = nil, **opts, &block) ⇒ Object
Override the attribute to really call “key” in the hash (for temporary backwards compat)
32 33 34 35 |
# File 'lib/praxis/action_definition/headers_dsl_compiler.rb', line 32 def attribute(name, attr_type=nil, **opts, &block) warn "[DEPRECATION] `attribute` is deprecated when defining headers. Please use `key` instead." key(name, attr_type, **opts, &block) end |
#header(name, val = nil, **options) ⇒ Object
it allows to define expectations on incoming headers. For example: header :X_SpecialCookie => implies the header is required header :X_Something, /matching_this/ => implies that if the name header exists, it should match the regexp header :X_A_Header, “Specific String” => implies that the value matches the string exactly In any of the cases, other supported options might be passed header :X_Something, /matching_this/ ,
required: true => to make it required
description: "lorem ipsum" => to describe it (like any other attribute)
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/praxis/action_definition/headers_dsl_compiler.rb', line 14 def header(name, val=nil, **) if val.kind_of?(Class) return key name, val, ** end case val when Regexp [:regexp] = val when String [:values] = [val] when nil # Defining the existence without any other options can only mean that it is required (otherwise it is a useless definition) [:required] = true if .empty? end key name , String, end |