Class: RailsBestPractices::Prepares::SchemaPrepare
- Inherits:
-
Core::Check
- Object
- Core::Check
- RailsBestPractices::Prepares::SchemaPrepare
- Defined in:
- lib/rails_best_practices/prepares/schema_prepare.rb
Overview
Remember the model attributes.
Constant Summary collapse
- ATTRIBUTE_TYPES =
all attribute types
%w(integer float boolean string text date time datetime binary)
Constants inherited from Core::Check
Core::Check::ALL_FILES, Core::Check::CONTROLLER_FILES, Core::Check::DEPLOY_FILES, Core::Check::HELPER_FILES, Core::Check::MAILER_FILES, Core::Check::MIGRATION_FILES, Core::Check::MODEL_FILES, Core::Check::PARTIAL_VIEW_FILES, Core::Check::ROUTE_FILES, Core::Check::SCHEMA_FILE, Core::Check::VIEW_FILES
Instance Method Summary collapse
-
#initialize ⇒ SchemaPrepare
constructor
A new instance of SchemaPrepare.
- #start_command(node) ⇒ Object
-
#start_command_call(node) ⇒ Object
check command_call node to remember the model attributes.
Methods inherited from Core::Check
add_callback, #add_error, #after_prepare, #after_review, callbacks, #errors, #increment_total_files_checked!, interesting_files, #interesting_files, interesting_nodes, #interesting_nodes, #method_missing, #node_end, #node_start, #parse_file?, #result, #total_files_checked, #url
Constructor Details
#initialize ⇒ SchemaPrepare
Returns a new instance of SchemaPrepare.
14 15 16 |
# File 'lib/rails_best_practices/prepares/schema_prepare.rb', line 14 def initialize @model_attributes = Prepares.model_attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RailsBestPractices::Core::Check
Instance Method Details
#start_command(node) ⇒ Object
18 19 20 21 22 |
# File 'lib/rails_best_practices/prepares/schema_prepare.rb', line 18 def start_command(node) if "create_table" == node..to_s @last_klazz = node.arguments.all.first.to_s.classify end end |
#start_command_call(node) ⇒ Object
check command_call node to remember the model attributes.
25 26 27 28 29 30 |
# File 'lib/rails_best_practices/prepares/schema_prepare.rb', line 25 def start_command_call(node) if ATTRIBUTE_TYPES.include? node..to_s attribute_name = node.arguments.all.first.to_s @model_attributes.add_attribute(@last_klazz, attribute_name, node..to_s) end end |