Sha256: 0bdc95c9eeb9000ab771d2d9e29fd9afb7285d23bbc2d70b61d4c2694653a364

Contents?: true

Size: 783 Bytes

Versions: 5

Compression:

Stored size: 783 Bytes

Contents

module DiviningRod
  module Profiler

    def initialize(request)
      @request = request
    end

    def match
      @match ||= DiviningRod::Mappings.evaluate(@request)
    end

    def format
      if match && match.format
        match.format
      else
        @request.format
      end
    end

    def recognized?
      match != DiviningRod::Mappings.root_definition
    end

    def tagged?(tag)
      if match
        Array(match.tags).include?(tag.to_sym)
      else
        false
      end
    end

    def method_missing(meth)
      if meth.to_s.match(/(.+)\?$/)
        tag = $1
        tagged?(tag)
      elsif match.opts.include?(meth.to_sym)
        match.opts[meth]
      else
        super
      end
    end

  end

  class Profile
    include Profiler
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
divining_rod-0.6.4 lib/divining_rod/profile.rb
divining_rod-0.6.3 lib/divining_rod/profile.rb
divining_rod-0.6.2 lib/divining_rod/profile.rb
divining_rod-0.6.1 lib/divining_rod/profile.rb
divining_rod-0.6.0 lib/divining_rod/profile.rb