Module: YamlDb::Anonymizer
- Defined in:
- lib/yaml_db/anonymizer.rb,
lib/yaml_db/anonymizer/dump.rb,
lib/yaml_db/anonymizer/helper.rb,
lib/yaml_db/anonymizer/railtie.rb,
lib/yaml_db/anonymizer/version.rb
Defined Under Namespace
Modules: Helper
Classes: Dump, Railtie
Constant Summary
collapse
- VERSION =
"0.0.3"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.definition ⇒ Object
Returns the value of attribute definition.
11
12
13
|
# File 'lib/yaml_db/anonymizer.rb', line 11
def definition
@definition
end
|
Class Method Details
.anonymize(table, column, value) ⇒ Object
36
37
38
39
40
41
42
43
44
|
# File 'lib/yaml_db/anonymizer.rb', line 36
def anonymize(table, column, value)
return value unless self.definition.key?(table.to_s) and self.definition[table.to_s].key?(column.to_s)
block_or_value = self.definition[table.to_s][column.to_s]
if block_or_value.is_a?(Proc)
block_or_value.arity == 1 ? block_or_value.call(value) : block_or_value.call
else
block_or_value
end
end
|
.define(*args, &block) ⇒ Object
13
14
15
16
|
# File 'lib/yaml_db/anonymizer.rb', line 13
def define(*args, &block)
self.definition = {}
class_eval &block
end
|
.remove(column_name) ⇒ Object
28
29
30
|
# File 'lib/yaml_db/anonymizer.rb', line 28
def remove(column_name)
self.definition[@table_name][column_name.to_s] = nil
end
|
.replace(column_name, opts = {}) ⇒ Object
32
33
34
|
# File 'lib/yaml_db/anonymizer.rb', line 32
def replace(column_name, opts={})
self.definition[@table_name][column_name.to_s] = opts[:with]
end
|
.table(table_name, &block) ⇒ Object
18
19
20
21
22
|
# File 'lib/yaml_db/anonymizer.rb', line 18
def table(table_name, &block)
@table_name = table_name.to_s
self.definition[@table_name] = {}
class_eval &block
end
|
.truncate ⇒ Object
24
25
26
|
# File 'lib/yaml_db/anonymizer.rb', line 24
def truncate
self.definition[@table_name] = :truncate
end
|