Module: DiviningRod::Profiler

Included in:
Profile
Defined in:
lib/divining_rod/profile.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'lib/divining_rod/profile.rb', line 32

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

Instance Method Details

#formatObject



12
13
14
15
16
17
18
# File 'lib/divining_rod/profile.rb', line 12

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

#initialize(request) ⇒ Object



4
5
6
# File 'lib/divining_rod/profile.rb', line 4

def initialize(request)
  @request = request
end

#matchObject



8
9
10
# File 'lib/divining_rod/profile.rb', line 8

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

#recognized?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/divining_rod/profile.rb', line 20

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

#tagged?(tag) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
# File 'lib/divining_rod/profile.rb', line 24

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