Class: RailsBestPractices::Prepares::MailerPrepare

Inherits:
Core::Check
  • Object
show all
Defined in:
lib/rails_best_practices/prepares/mailer_prepare.rb

Overview

Remember the mailer names.

Constant Summary

Constants inherited from Core::Check

Core::Check::CONTROLLER_FILES, Core::Check::HELPER_FILES, Core::Check::MAILER_FILES, Core::Check::MIGRATION_FILES, Core::Check::MODEL_FILES, Core::Check::NODE_TYPES, Core::Check::PARTIAL_VIEW_FILES, Core::Check::ROUTE_FILE, Core::Check::SCHEMA_FILE, Core::Check::VIEW_FILES

Instance Attribute Summary

Attributes inherited from Core::Check

#errors

Instance Method Summary collapse

Methods inherited from Core::Check

#add_error, #method_missing, #node_end, #node_start, #url

Constructor Details

#initializeMailerPrepare

Returns a new instance of MailerPrepare.



17
18
19
# File 'lib/rails_best_practices/prepares/mailer_prepare.rb', line 17

def initialize
  @mailers = Core::Mailers.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RailsBestPractices::Core::Check

Instance Method Details

#interesting_filesObject



13
14
15
# File 'lib/rails_best_practices/prepares/mailer_prepare.rb', line 13

def interesting_files
  /#{MAILER_FILES}|#{MODEL_FILES}/
end

#interesting_nodesObject



9
10
11
# File 'lib/rails_best_practices/prepares/mailer_prepare.rb', line 9

def interesting_nodes
  [:class]
end

#start_class(class_node) ⇒ Object

check class node.

if it is a subclass of ActionMailer::Base, then remember its class name.



25
26
27
28
29
30
# File 'lib/rails_best_practices/prepares/mailer_prepare.rb', line 25

def start_class(class_node)
  if s(:colon2, s(:const, :ActionMailer), :Base) == class_node.base_class
    @mailers << class_node.class_name.to_s
    Prepares.mailers = @mailers
  end
end