Module: EncryptedAttributes
- Defined in:
- lib/encrypted_attributes.rb,
lib/encrypted_attributes/ar_23.rb,
lib/encrypted_attributes/ar_32.rb,
lib/encrypted_attributes/railtie.rb
Defined Under Namespace
Modules: AR23, AR32
Classes: Railtie
Class Method Summary
collapse
Class Method Details
.decrypt(value) ⇒ Object
20
21
22
|
# File 'lib/encrypted_attributes.rb', line 20
def self.decrypt(value)
@encrypter.decrypt(value)
end
|
.encrypt(value) ⇒ Object
16
17
18
|
# File 'lib/encrypted_attributes.rb', line 16
def self.encrypt(value)
@encrypter.encrypt(value)
end
|
.extended(base) ⇒ Object
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/encrypted_attributes.rb', line 2
def self.extended(base)
ar_version = Gem::Version.new(ActiveRecord::VERSION::STRING)
if Gem::Requirement.new('~> 2.3.0').satisfied_by? ar_version
require 'encrypted_attributes/ar_23'
base.send :extend, AR23
elsif Gem::Requirement.new('~> 3.2.0').satisfied_by? ar_version
require 'encrypted_attributes/ar_32'
base.send :extend, AR32
else
fail "Unsupported version of ActiveRecord."
end
end
|
.setup(attrs = {}) ⇒ Object
24
25
26
|
# File 'lib/encrypted_attributes.rb', line 24
def self.setup(attrs={})
@encrypter = SimpleAES.new(:key => attrs.fetch(:key), :iv => attrs.fetch(:iv))
end
|