Class: BlastRadius::Analyzer
- Inherits:
-
Object
- Object
- BlastRadius::Analyzer
- Defined in:
- lib/blast_radius/analyzer.rb
Instance Method Summary collapse
-
#all_models ⇒ Array<Class>
Get all models in Rails application.
-
#analyze(model_class) ⇒ Array<Hash>
Analyze model associations and extract those with dependent options.
Instance Method Details
#all_models ⇒ Array<Class>
Get all models in Rails application
30 31 32 33 34 35 36 37 |
# File 'lib/blast_radius/analyzer.rb', line 30 def all_models if defined?(Rails) Rails.application.eager_load! ApplicationRecord.descendants else [] end end |
#analyze(model_class) ⇒ Array<Hash>
Analyze model associations and extract those with dependent options
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/blast_radius/analyzer.rb', line 14 def analyze(model_class) return [] unless valid_model?(model_class) associations = [] model_class.reflect_on_all_associations.each do |reflection| next unless has_dependent_option?(reflection) associations << build_association_info(reflection) end associations end |