Sha256: 8d83a4f614302ef670a3b16ddff5c15ea4e761d30c7f30cbf0ea1f1954a40ade

Contents?: true

Size: 510 Bytes

Versions: 5

Compression:

Stored size: 510 Bytes

Contents

module XRayMachine
  class XRay
    def cached
      @cached || false
    end

    def cached=(val)
      @cached = val
    end

    alias :cached? :cached

    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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
x-ray-machine-1.0.4 lib/x_ray_machine/x_ray.rb
x-ray-machine-1.0.3 lib/x_ray_machine/x_ray.rb
x-ray-machine-1.0.2 lib/x_ray_machine/x_ray.rb
x-ray-machine-1.0.1 lib/x_ray_machine/x_ray.rb
x-ray-machine-1.0.0 lib/x_ray_machine/x_ray.rb