Class: AttributeStats::HashFormatter
- Inherits:
-
Object
- Object
- AttributeStats::HashFormatter
- Defined in:
- lib/formatters/hash_formatter.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(options: {}, table_info: {}, migration: []) ⇒ HashFormatter
constructor
A new instance of HashFormatter.
- #output_all_attributes ⇒ Object
- #output_dormant_tables ⇒ Object
- #output_unused_attributes ⇒ Object
Constructor Details
#initialize(options: {}, table_info: {}, migration: []) ⇒ HashFormatter
4 5 6 |
# File 'lib/formatters/hash_formatter.rb', line 4 def initialize(options: {}, table_info: {}, migration: []) , @table_info, @migration = , table_info, migration end |
Instance Method Details
#output_all_attributes ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/formatters/hash_formatter.rb', line 8 def output_all_attributes output = [] @table_info.each do |table_info| table_info.attributes.each do |attribute| output << { model: table_info.name, attribute: attribute.name, count: attribute.count, usage_percent: attribute.usage_percent } end end output end |
#output_dormant_tables ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/formatters/hash_formatter.rb', line 23 def output_dormant_tables output = [] @table_info.each do |table_info| output << table_info.table_name if table_info.dormant? end output end |
#output_unused_attributes ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/formatters/hash_formatter.rb', line 31 def output_unused_attributes output = [] @table_info.each do |table_info| table_info.attributes.sort_by(&:name).each do |attribute| next unless attribute.empty? output << { model: table_info.name, attribute: attribute.name } end end output end |