Class: Polo::Configuration
- Inherits:
-
Object
- Object
- Polo::Configuration
- Defined in:
- lib/polo/configuration.rb
Instance Attribute Summary collapse
-
#blacklist ⇒ Object
readonly
Returns the value of attribute blacklist.
-
#on_duplicate_strategy ⇒ Object
readonly
Returns the value of attribute on_duplicate_strategy.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Configuration
constructor
A new instance of Configuration.
-
#obfuscate(*fields) ⇒ Object
TODO: document this This normalizes an array or hash of fields to a hash of { field_name => strategy }.
- #on_duplicate(strategy) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Returns a new instance of Configuration.
6 7 8 9 10 |
# File 'lib/polo/configuration.rb', line 6 def initialize(={}) = { on_duplicate: nil, obfuscate: {} }.merge() @on_duplicate_strategy = [:on_duplicate] obfuscate([:obfuscate]) end |
Instance Attribute Details
#blacklist ⇒ Object (readonly)
Returns the value of attribute blacklist.
4 5 6 |
# File 'lib/polo/configuration.rb', line 4 def blacklist @blacklist end |
#on_duplicate_strategy ⇒ Object (readonly)
Returns the value of attribute on_duplicate_strategy.
4 5 6 |
# File 'lib/polo/configuration.rb', line 4 def on_duplicate_strategy @on_duplicate_strategy end |
Instance Method Details
#obfuscate(*fields) ⇒ Object
TODO: document this This normalizes an array or hash of fields to a hash of { field_name => strategy }
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/polo/configuration.rb', line 15 def obfuscate(*fields) if fields.is_a?(Array) fields = fields.flatten end fields_and_strategies = {} fields.each do |field| if field.is_a?(Symbol) || field.is_a?(String) fields_and_strategies[field] = nil elsif field.is_a?(Hash) fields_and_strategies = fields_and_strategies.merge(field) end end @blacklist = fields_and_strategies end |
#on_duplicate(strategy) ⇒ Object
33 34 35 |
# File 'lib/polo/configuration.rb', line 33 def on_duplicate(strategy) @on_duplicate_strategy = strategy end |