Class: Lagoon::Parser::ModelParser
- Inherits:
-
Object
- Object
- Lagoon::Parser::ModelParser
- Defined in:
- lib/lagoon/parser/model_parser.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ModelParser
constructor
A new instance of ModelParser.
- #parse ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ModelParser
Returns a new instance of ModelParser.
12 13 14 15 16 |
# File 'lib/lagoon/parser/model_parser.rb', line 12 def initialize( = {}) @options = .is_a?(Options) ? : Options.for(:model, ) @analyzer = Lagoon::Analyzer::ActiveRecordAnalyzer.new @filter = ApplicationClassFilter.new(directory: 'models', include_all: @options[:all_models]) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/lagoon/parser/model_parser.rb', line 10 def config @config end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
10 11 12 |
# File 'lib/lagoon/parser/model_parser.rb', line 10 def @options end |
Instance Method Details
#parse ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lagoon/parser/model_parser.rb', line 18 def parse models = load_models classes = [] relationships = [] warnings = [] models.sort_by { |model| model.name.to_s }.each do |model| next if excluded?(model) analyze_model(model, classes, relationships) rescue StandardError => e raise if [:strict] warnings << "Failed to analyze model #{model.name || '(anonymous)'}: #{e.}" end normalized_relationships = deduplicate_relationships(relationships) { classes: classes.sort_by { |model| model[:name] }, relationships: normalized_relationships, warnings: warnings, counts: { classes: classes.size, relationships: normalized_relationships.size, skipped: warnings.size } } end |