Class: Ahnnotate::Facet::Models::Main
- Inherits:
-
Object
- Object
- Ahnnotate::Facet::Models::Main
- Defined in:
- lib/ahnnotate/facet/models/main.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(config, tables, vfs) ⇒ Main
constructor
A new instance of Main.
- #model_nodes ⇒ Object
Constructor Details
#initialize(config, tables, vfs) ⇒ Main
Returns a new instance of Main.
7 8 9 10 11 |
# File 'lib/ahnnotate/facet/models/main.rb', line 7 def initialize(config, tables, vfs) @config = config @tables = tables @vfs = vfs end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ahnnotate/facet/models/main.rb', line 13 def call formatter = Function::Format.new(comment: "#") model_nodes.each do |model_node| table = @tables[model_node.table_name] if table.nil? next end @vfs[model_node.path] = formatter.call(table, @vfs[model_node.path]) end end |
#model_nodes ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ahnnotate/facet/models/main.rb', line 28 def model_nodes @model_nodes ||= begin model_path = @config["annotate", "models", "path"] model_extension = @config["annotate", "models", "extension"] model_files = @vfs.each_in(model_path, model_extension) processor = Processor.new models = model_files.map do |path, contents| module_nodes = processor.call(contents) module_nodes.each { |node| node.path = path } module_nodes end models .flatten .yield_self(&ResolveClassRelationships.new) .yield_self(&ResolveActiveRecordModels.new) .select(&:is_a_kind_of_activerecord_base?) .reject(&:abstract_class?) end end |