Module: Redmine::Ciphering::ClassMethods

Defined in:
lib/redmine/ciphering.rb

Instance Method Summary collapse

Instance Method Details

#decrypt_all(attribute) ⇒ Object



82
83
84
85
86
87
88
89
90
# File 'lib/redmine/ciphering.rb', line 82

def decrypt_all(attribute)
  transaction do
    all.each do |object|
      clear = object.send(attribute)
      object.send :write_attribute, attribute, clear
      raise(ActiveRecord::Rollback) unless object.save(validate: false)
    end
  end ? true : false
end

#encrypt_all(attribute) ⇒ Object



72
73
74
75
76
77
78
79
80
# File 'lib/redmine/ciphering.rb', line 72

def encrypt_all(attribute)
  transaction do
    all.each do |object|
      clear = object.send(attribute)
      object.send :"#{attribute}=", clear
      raise(ActiveRecord::Rollback) unless object.save(validate: false)
    end
  end ? true : false
end