lib/divining_rod/profile.rb in divining_rod-0.5.0 vs lib/divining_rod/profile.rb in divining_rod-0.6.0
- old
+ new
@@ -1,12 +1,12 @@
module DiviningRod
- class Profile
+ module Profiler
def initialize(request)
- @request = request.clone #Lets not mess with the real one
+ @request = request
end
-
+
def match
@match ||= DiviningRod::Mappings.evaluate(@request)
end
def format
@@ -19,22 +19,31 @@
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
- if match
- match.tags.include?(tag.to_s) || match.tags.include?(tag.to_sym) || match.tags == tag
- else
- false
- end
+ tagged?(tag)
elsif match.opts.include?(meth.to_sym)
match.opts[meth]
else
super
end
end
end
+
+ class Profile
+ include Profiler
+ end
end
+