Class: Dropkiq::DropClassAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/dropkiq/drop_class_analyzer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(liquid_drop_class) ⇒ DropClassAnalyzer

Returns a new instance of DropClassAnalyzer.



6
7
8
# File 'lib/dropkiq/drop_class_analyzer.rb', line 6

def initialize(liquid_drop_class)
  self.liquid_drop_class = liquid_drop_class
end

Instance Attribute Details

#active_record_classObject

Returns the value of attribute active_record_class.



3
4
5
# File 'lib/dropkiq/drop_class_analyzer.rb', line 3

def active_record_class
  @active_record_class
end

#drop_method_paramsObject

Returns the value of attribute drop_method_params.



3
4
5
# File 'lib/dropkiq/drop_class_analyzer.rb', line 3

def drop_method_params
  @drop_method_params
end

#liquid_drop_classObject

Returns the value of attribute liquid_drop_class.



3
4
5
# File 'lib/dropkiq/drop_class_analyzer.rb', line 3

def liquid_drop_class
  @liquid_drop_class
end

#table_nameObject

Returns the value of attribute table_name.



3
4
5
# File 'lib/dropkiq/drop_class_analyzer.rb', line 3

def table_name
  @table_name
end

Instance Method Details

#analyzeObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dropkiq/drop_class_analyzer.rb', line 10

def analyze
  self.active_record_class = find_active_record_class
  self.active_record_class ||= find_active_record_class_from_shim

  if active_record_class.blank?
    puts "WARNING: No ActiveRecord Class found for #{liquid_drop_class.name} (skipping)"
    return
  end

  self.table_name = active_record_class.table_name
  self.drop_method_params = find_drop_method_params
end

#to_paramObject



23
24
25
26
27
28
29
30
31
# File 'lib/dropkiq/drop_class_analyzer.rb', line 23

def to_param
  return {} if active_record_class.blank?

  {
    "#{table_name}" => {
      "methods" => drop_method_params
    }
  }
end