Class: Dropkiq::DropMethodAnalyzer
- Inherits:
-
Object
- Object
- Dropkiq::DropMethodAnalyzer
- Defined in:
- lib/dropkiq/drop_method_analyzer.rb
Constant Summary collapse
- CHANGEME =
"CHANGEME"
Instance Attribute Summary collapse
-
#drop_class_analyzer ⇒ Object
Returns the value of attribute drop_class_analyzer.
-
#drop_method ⇒ Object
Returns the value of attribute drop_method.
-
#dropkiq_type ⇒ Object
Returns the value of attribute dropkiq_type.
-
#foreign_table_name ⇒ Object
Returns the value of attribute foreign_table_name.
-
#sample_drop ⇒ Object
Returns the value of attribute sample_drop.
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(drop_class_analyzer, drop_method, sample_drop = nil) ⇒ DropMethodAnalyzer
constructor
A new instance of DropMethodAnalyzer.
- #to_param ⇒ Object
Constructor Details
#initialize(drop_class_analyzer, drop_method, sample_drop = nil) ⇒ DropMethodAnalyzer
Returns a new instance of DropMethodAnalyzer.
10 11 12 13 14 |
# File 'lib/dropkiq/drop_method_analyzer.rb', line 10 def initialize(drop_class_analyzer, drop_method, sample_drop=nil) self.drop_class_analyzer = drop_class_analyzer self.drop_method = drop_method self.sample_drop = sample_drop end |
Instance Attribute Details
#drop_class_analyzer ⇒ Object
Returns the value of attribute drop_class_analyzer.
5 6 7 |
# File 'lib/dropkiq/drop_method_analyzer.rb', line 5 def drop_class_analyzer @drop_class_analyzer end |
#drop_method ⇒ Object
Returns the value of attribute drop_method.
5 6 7 |
# File 'lib/dropkiq/drop_method_analyzer.rb', line 5 def drop_method @drop_method end |
#dropkiq_type ⇒ Object
Returns the value of attribute dropkiq_type.
5 6 7 |
# File 'lib/dropkiq/drop_method_analyzer.rb', line 5 def dropkiq_type @dropkiq_type end |
#foreign_table_name ⇒ Object
Returns the value of attribute foreign_table_name.
5 6 7 |
# File 'lib/dropkiq/drop_method_analyzer.rb', line 5 def foreign_table_name @foreign_table_name end |
#sample_drop ⇒ Object
Returns the value of attribute sample_drop.
5 6 7 |
# File 'lib/dropkiq/drop_method_analyzer.rb', line 5 def sample_drop @sample_drop end |
Instance Method Details
#analyze ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dropkiq/drop_method_analyzer.rb', line 16 def analyze self.dropkiq_type = if is_relationship? relationship_to_dropkiq_type_classifier elsif is_column? column_to_dropkiq_type_classifier else Dropkiq::DropMethodNameClassifier.new(drop_method).classify end if dropkiq_type.blank? result = Dropkiq::DropMethodInstanceSimulator.new(drop_method, sample_drop).classify self.dropkiq_type = result.dropkiq_type self.foreign_table_name = result.foreign_table_name end end |
#to_param ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/dropkiq/drop_method_analyzer.rb', line 32 def to_param { "#{drop_method}" => { "type" => (dropkiq_type.presence || CHANGEME), "foreign_table_name" => foreign_table_name } } end |