Class: Witsec::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/witsec/schema.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ Schema

Returns a new instance of Schema.



9
10
11
12
13
# File 'lib/witsec/schema.rb', line 9

def initialize(version)
  @version = version
  @anonymized_tables = []
  @excluded_tables = []
end

Instance Attribute Details

#anonymized_tablesObject (readonly)

Returns the value of attribute anonymized_tables.



15
16
17
# File 'lib/witsec/schema.rb', line 15

def anonymized_tables
  @anonymized_tables
end

#excluded_tablesObject (readonly)

Returns the value of attribute excluded_tables.



15
16
17
# File 'lib/witsec/schema.rb', line 15

def excluded_tables
  @excluded_tables
end

#versionObject (readonly)

Returns the value of attribute version.



15
16
17
# File 'lib/witsec/schema.rb', line 15

def version
  @version
end

Class Method Details

.define(version, &block) ⇒ Object



4
5
6
# File 'lib/witsec/schema.rb', line 4

def define(version, &block)
  new(version).define(&block)
end

Instance Method Details

#anonymize_table(name, &block) ⇒ Object



31
32
33
34
35
# File 'lib/witsec/schema.rb', line 31

def anonymize_table(name, &block)
  anonymized_tables << Table.new(name).define do
    instance_eval(&block)
  end
end

#anonymizes?(table_name) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/witsec/schema.rb', line 37

def anonymizes?(table_name)
  anonymized_table_names.include?(table_name)
end

#define(&block) ⇒ Object



17
18
19
20
21
# File 'lib/witsec/schema.rb', line 17

def define(&block)
  instance_eval(&block)

  self
end

#exclude_table(name) ⇒ Object



23
24
25
# File 'lib/witsec/schema.rb', line 23

def exclude_table(name)
  excluded_tables << name
end

#include_table(name) ⇒ Object



27
28
29
# File 'lib/witsec/schema.rb', line 27

def include_table(name)
  anonymized_tables << Table.new(name)
end

#table_namesObject



41
42
43
# File 'lib/witsec/schema.rb', line 41

def table_names
  (anonymized_table_names + excluded_tables).sort
end