Class: DBPurger::Table
- Inherits:
-
Object
- Object
- DBPurger::Table
- Defined in:
- lib/db-purger/table.rb
Overview
DBPurger::Table is an entity to keep track of basic table data
Constant Summary collapse
- DEFAULT_BATCH_SIZE =
10_000
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#conditions ⇒ Object
Returns the value of attribute conditions.
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#foreign_key ⇒ Object
Returns the value of attribute foreign_key.
-
#mark_deleted_field ⇒ Object
Returns the value of attribute mark_deleted_field.
- #mark_deleted_value ⇒ Object
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#search_proc ⇒ Object
Returns the value of attribute search_proc.
Instance Method Summary collapse
- #fields ⇒ Object
- #foreign_keys ⇒ Object
-
#initialize(name, field) ⇒ Table
constructor
A new instance of Table.
- #nested_plan(&block) ⇒ Object
- #nested_tables? ⇒ Boolean
- #tables ⇒ Object
Constructor Details
#initialize(name, field) ⇒ Table
Returns a new instance of Table.
19 20 21 22 23 |
# File 'lib/db-purger/table.rb', line 19 def initialize(name, field) @name = name @field = field @batch_size = DEFAULT_BATCH_SIZE end |
Instance Attribute Details
#batch_size ⇒ Object
Returns the value of attribute batch_size.
8 9 10 |
# File 'lib/db-purger/table.rb', line 8 def batch_size @batch_size end |
#conditions ⇒ Object
Returns the value of attribute conditions.
8 9 10 |
# File 'lib/db-purger/table.rb', line 8 def conditions @conditions end |
#field ⇒ Object (readonly)
Returns the value of attribute field.
16 17 18 |
# File 'lib/db-purger/table.rb', line 16 def field @field end |
#foreign_key ⇒ Object
Returns the value of attribute foreign_key.
8 9 10 |
# File 'lib/db-purger/table.rb', line 8 def foreign_key @foreign_key end |
#mark_deleted_field ⇒ Object
Returns the value of attribute mark_deleted_field.
8 9 10 |
# File 'lib/db-purger/table.rb', line 8 def mark_deleted_field @mark_deleted_field end |
#mark_deleted_value ⇒ Object
47 48 49 |
# File 'lib/db-purger/table.rb', line 47 def mark_deleted_value @mark_deleted_value || 1 end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
16 17 18 |
# File 'lib/db-purger/table.rb', line 16 def name @name end |
#search_proc ⇒ Object
Returns the value of attribute search_proc.
8 9 10 |
# File 'lib/db-purger/table.rb', line 8 def search_proc @search_proc end |
Instance Method Details
#fields ⇒ Object
43 44 45 |
# File 'lib/db-purger/table.rb', line 43 def fields [@field] + foreign_keys end |
#foreign_keys ⇒ Object
39 40 41 |
# File 'lib/db-purger/table.rb', line 39 def foreign_keys @nested_plan ? @nested_plan.foreign_tables.map(&:foreign_key).compact : [] end |
#nested_plan(&block) ⇒ Object
25 26 27 28 29 |
# File 'lib/db-purger/table.rb', line 25 def nested_plan(&block) @nested_plan ||= Plan.new PlanBuilder.new(@nested_plan).build_nested_plan(self, &block) if block @nested_plan end |
#nested_tables? ⇒ Boolean
31 32 33 |
# File 'lib/db-purger/table.rb', line 31 def nested_tables? @nested_plan != nil end |
#tables ⇒ Object
35 36 37 |
# File 'lib/db-purger/table.rb', line 35 def tables @nested_plan ? @nested_plan.tables : [] end |