Module: ObscurifyAttribute::Validations::ClassMethods

Defined in:
lib/obscurify_attribute/validations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#sensitive_attrsObject (readonly)

Returns the value of attribute sensitive_attrs.



10
11
12
# File 'lib/obscurify_attribute/validations.rb', line 10

def sensitive_attrs
  @sensitive_attrs
end

Instance Method Details

#obscurify(*args) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/obscurify_attribute/validations.rb', line 12

def obscurify(*args)
  options = args.extract_options!
  args.reject!(&:blank?)
  options.symbolize_keys!
  options.assert_valid_keys(:message)
  to_name = args.pop
  raise(ArgumentError, "Should specify a second (target) attribute name") if args.empty?
  args.inject(sensitive_attrs) do |h, attr|
    h[attr] = {:to => to_name}.merge(options)
    h
  end
end