Parent

Files

Class/Module Index [+]

Quicksearch

Dragonfly::Analyser

Attributes

analysis_method_names[R]
analysis_methods[R]

Public Class Methods

new() click to toggle source
# File lib/dragonfly/analyser.rb, line 7
def initialize
  super
  analyser = self
  @analysis_methods = Module.new do

    define_method :analyser do
      analyser
    end
    
  end
  @analysis_method_names = []
end

Public Instance Methods

add(name, *args, &block) click to toggle source

Each time a function is registered with the analyser, add a method to the analysis_methods module. Expects the object that is extended to define 'analyse(method, *args)'

# File lib/dragonfly/analyser.rb, line 37
def add(name, *args, &block)
  analysis_methods.module_eval %(
    def #{name}(*args)
      analyse(:#{name}, *args)
    end
  )
  analysis_method_names << name.to_sym
  super
end
analyse(temp_object, method, *args) click to toggle source
# File lib/dragonfly/analyser.rb, line 22
def analyse(temp_object, method, *args)
  if enable_cache
    key = [temp_object.unique_id, method, *args]
    cache[key] ||= call_last(method, temp_object, *args)
  else
    call_last(method, temp_object, *args)
  end
rescue NotDefined, UnableToHandle => e
  log.warn(e.message)
  nil
end
clear_cache!() click to toggle source
# File lib/dragonfly/analyser.rb, line 47
def clear_cache!
  @cache = nil
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.