Class: Samidare::MySQL::TableConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/samidare/mysql.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ TableConfig

Returns a new instance of TableConfig.



44
45
46
47
48
# File 'lib/samidare/mysql.rb', line 44

def initialize(config)
  @name = config['name']
  @daily_snapshot = config['daily_snapshot'] || false
  @condition = config['condition']
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



42
43
44
# File 'lib/samidare/mysql.rb', line 42

def condition
  @condition
end

#daily_snapshotObject (readonly)

Returns the value of attribute daily_snapshot.



42
43
44
# File 'lib/samidare/mysql.rb', line 42

def daily_snapshot
  @daily_snapshot
end

#nameObject (readonly)

Returns the value of attribute name.



42
43
44
# File 'lib/samidare/mysql.rb', line 42

def name
  @name
end

Class Method Details

.generate_table_configs(file_path = 'table.yml') ⇒ Object



50
51
52
53
54
55
56
# File 'lib/samidare/mysql.rb', line 50

def self.generate_table_configs(file_path = 'table.yml')
  configs = YAML.load_file(file_path)
  configs.each_with_object({}) do |(db, database_config), table_configs|
    table_configs[db] = database_config['tables'].map { |config| TableConfig.new(config) }
    table_configs
  end
end

Instance Method Details

#==(another) ⇒ Object



58
59
60
61
62
# File 'lib/samidare/mysql.rb', line 58

def ==(another)
  self.instance_variables.all? do |v|
    self.instance_variable_get(v) == another.instance_variable_get(v)
  end
end