Method: Wants::MatchResult#method_missing

Defined in:
lib/wants/match_result.rb

#method_missing(method, *args, &block) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/wants/match_result.rb', line 38

def method_missing(method, *args, &block)
  if mime = mime_abbreviation_from_method(method)
    if args.length > 0
      raise ArgumentError, "wrong number of arguments (#{args.length} for 0)"
    end
    if method =~ /\?$/
      self[mime]
    elsif self[mime]
      @response_value ||= block.call
    else
      @response_value
    end
  else
    super
  end
end