Class: Configuration::HandlerStatement::ConditionalInclusion::VariableMatches

Inherits:
Object
  • Object
show all
Defined in:
lib/httpimagestore/configuration/handler/statement.rb

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ VariableMatches

Returns a new instance of VariableMatches.



65
66
67
68
69
# File 'lib/httpimagestore/configuration/handler/statement.rb', line 65

def initialize(value)
	param_name, template = value.split(':', 2)
	@param_name = param_name.to_sym if param_name
	@template = template.to_template if template
end

Instance Method Details

#included?(request_state) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
# File 'lib/httpimagestore/configuration/handler/statement.rb', line 71

def included?(request_state)
	return false if not @param_name
	return !request_state[@param_name].empty? if not @template
	@template.render(request_state) == request_state[@param_name]
rescue Configuration::VariableNotDefinedError
	false
end