Class: Waves::Matchers::Accept
Overview
TODO:
Rename to Negotiation? –rue
Instance Method Summary collapse
-
#[](request) ⇒ Object
Proc-like interface.
-
#call(request) ⇒ Object
Verify that any and all Accept constraints match.
-
#initialize(options) ⇒ Accept
constructor
Set up Accept parsing.
Constructor Details
#initialize(options) ⇒ Accept
Set up Accept parsing.
Only the defined constraints are included.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/waves/matchers/accept.rb', line 12 def initialize() @constraints = {} { :accept => :accept, :charset => :accept_charset, :lang => :accept_lang }.each { |key,method| if [key] if [key].is_a? Array @constraints[method] = [key] unless [key].empty? else @constraints[method] = [ [key] ] end end } end |
Instance Method Details
#[](request) ⇒ Object
Proc-like interface
38 39 40 |
# File 'lib/waves/matchers/accept.rb', line 38 def [](request) call request end |
#call(request) ⇒ Object
Verify that any and all Accept constraints match.
Request handles these.
32 33 34 |
# File 'lib/waves/matchers/accept.rb', line 32 def call(request) @constraints.all? { |key, val| request.send(key).include? val } end |