Sha256: f6d98f09addf5aea7f54ac7db8e7a7c8f53eeab51d13d04a2880207f76cc2b2d

Contents?: true

Size: 786 Bytes

Versions: 1

Compression:

Stored size: 786 Bytes

Contents

module DiviningRod
  class Profile

    def initialize(request)
      @request = request.clone #Lets not mess with the real one
    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 method_missing(meth)
      if meth.to_s.match(/(.+)\?$/)
        tag = $1
        if match
          match.tags.include?(tag.to_s) ||  match.tags.include?(tag.to_sym) || match.tags == tag
        else
          false
        end
      elsif match.opts.include?(meth.to_sym)
        match.opts[meth]
      else
        super
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
divining_rod-0.5.0 lib/divining_rod/profile.rb