Class: AttributeStats::TableData
- Inherits:
-
Object
- Object
- AttributeStats::TableData
- Defined in:
- lib/entities/table_data.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#last_updated ⇒ Object
readonly
Returns the value of attribute last_updated.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
Instance Method Summary collapse
- #attribute_for(attribute_name) ⇒ Object
- #column_names ⇒ Object
- #dormant? ⇒ Boolean
-
#initialize(model) ⇒ TableData
constructor
A new instance of TableData.
- #make_dormant(last_updated) ⇒ Object
- #set_count(total_record_count) ⇒ Object
- #unused_attributes ⇒ Object
Constructor Details
#initialize(model) ⇒ TableData
Returns a new instance of TableData.
4 5 6 7 8 9 10 11 12 |
# 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 |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/entities/table_data.rb', line 3 def attributes @attributes end |
#count ⇒ Object (readonly)
Returns the value of attribute count.
3 4 5 |
# File 'lib/entities/table_data.rb', line 3 def count @count end |
#last_updated ⇒ Object (readonly)
Returns the value of attribute last_updated.
3 4 5 |
# File 'lib/entities/table_data.rb', line 3 def last_updated @last_updated end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/entities/table_data.rb', line 3 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/entities/table_data.rb', line 3 def name @name end |
#table_name ⇒ Object (readonly)
Returns the value of attribute table_name.
3 4 5 |
# File 'lib/entities/table_data.rb', line 3 def table_name @table_name end |
Instance Method Details
#attribute_for(attribute_name) ⇒ Object
32 33 34 35 36 37 38 |
# 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 ⇒ Object
14 15 16 |
# File 'lib/entities/table_data.rb', line 14 def column_names @column_names end |
#dormant? ⇒ Boolean
24 25 26 |
# File 'lib/entities/table_data.rb', line 24 def dormant? @dormant end |
#make_dormant(last_updated) ⇒ Object
18 19 20 21 22 |
# 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) ⇒ Object
28 29 30 |
# File 'lib/entities/table_data.rb', line 28 def set_count(total_record_count) @count = total_record_count end |
#unused_attributes ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/entities/table_data.rb', line 40 def unused_attributes @unused_attributes ||= begin attrs = [] @attributes.each do |attribute| attrs << attribute.name if attribute.empty? end attrs end end |