Parent

Files

RailsBestPractices::Checks::UseObserverCheck

Check a model file to make sure mail deliver method is in observer not callback.

Implementation: Record :after_create callback Check method define, if it is a callback and call deliver_xxx message in method body, then it should use observer.

Public Class Methods

new() click to toggle source
# File lib/rails_best_practices/checks/use_observer_check.rb, line 20
def initialize
  super
  @callbacks = []
end

Public Instance Methods

evaluate_start(node) click to toggle source
# File lib/rails_best_practices/checks/use_observer_check.rb, line 25
def evaluate_start(node)
  if :after_create == node.message
    remember_callbacks(node)
  elsif :defn == node.node_type and @callbacks.include?(node.message_name.to_s)
    add_error "use observer" if use_observer?(node)
  end
end
interesting_files() click to toggle source
# File lib/rails_best_practices/checks/use_observer_check.rb, line 16
def interesting_files
  MODLE_FILES
end
interesting_nodes() click to toggle source
# File lib/rails_best_practices/checks/use_observer_check.rb, line 12
def interesting_nodes
  [:defn, :call]
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.