Class: XRayMachine::XRay

Inherits:
Object
  • Object
show all
Defined in:
lib/x_ray_machine/x_ray.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.method_missing(name, query, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/x_ray_machine/x_ray.rb', line 13

def self.method_missing(name, query, &block)
  options = {group: name, query: query, cache: false}

  ActiveSupport::Notifications.instrument "request.xraymachine", options do
    ray = XRayMachine::XRay.new

    block.call(ray).tap do |result|
      options[:cache] = true if ray.cached?
    end
  end
end

Instance Method Details

#cachedObject Also known as: cached?



3
4
5
# File 'lib/x_ray_machine/x_ray.rb', line 3

def cached
  @cached || false
end

#cached=(val) ⇒ Object



7
8
9
# File 'lib/x_ray_machine/x_ray.rb', line 7

def cached=(val)
  @cached = val
end