class AttributeStats::TableData

Attributes

attributes[R]
count[R]
last_updated[R]
model[R]
name[R]
table_name[R]

Public Class Methods

new(model) click to toggle source
# File lib/entities/table_data.rb, line 4
def initialize(model)
  @model        = model
  @name         = model.name
  @table_name   = model.table_name
  @attributes   = []
  @dormant      = false
  @count        = 0
  @column_names = model.columns.map(&:name)
end

Public Instance Methods

attribute_for(attribute_name) click to toggle source
# File lib/entities/table_data.rb, line 32
def attribute_for(attribute_name)
  unless attribute = attributes.detect{|a| a.name == attribute_name }
    attribute = AttributeInfo.new(attribute_name)
    @attributes << attribute
  end
  attribute
end
column_names() click to toggle source
# File lib/entities/table_data.rb, line 14
def column_names
  @column_names
end
dormant?() click to toggle source
# File lib/entities/table_data.rb, line 24
def dormant?
  @dormant
end
make_dormant(last_updated) click to toggle source
# File lib/entities/table_data.rb, line 18
def make_dormant(last_updated)
  @dormant = true
  last_updated  = last_updated.to_datetime unless last_updated.nil?
  @last_updated = last_updated
end
set_count(total_record_count) click to toggle source
# File lib/entities/table_data.rb, line 28
def set_count(total_record_count)
  @count = total_record_count
end
unused_attribute_info() click to toggle source
# File lib/entities/table_data.rb, line 40
def unused_attribute_info
  @unused_attribute_info ||= begin
    attrs = []
    @attributes.each do |attribute|
      attrs << attribute if attribute.empty?
    end
    attrs
  end
end
unused_attributes() click to toggle source
# File lib/entities/table_data.rb, line 50
def unused_attributes
  @unused_attributes ||= unused_attribute_info.map(&:name)
end