hashed_attr 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{hash_attr.gemspec → hashed_attr.gemspec} +2 -2
- data/lib/hashed_attr.rb +17 -0
- data/lib/hashed_attr/active_record.rb +2 -0
- data/lib/{hash_attr → hashed_attr}/base.rb +7 -7
- data/lib/{hash_attr → hashed_attr}/encryptor.rb +1 -2
- data/lib/hashed_attr/version.rb +3 -0
- metadata +7 -7
- data/lib/hash_attr.rb +0 -17
- data/lib/hash_attr/active_record.rb +0 -2
- data/lib/hash_attr/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ffaafd0698989e95d8181ddc6d613031cb122c2
|
4
|
+
data.tar.gz: 738ccaf5ac722f0031e15bf2629f3e492e3e43bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 165148db1d23927161978cc7a22960837845084b3a230e2c2f30ee938cd53c28577bc67c8111e36e383812e2f7886941a15ef60b60ccf798e083a6122355640d
|
7
|
+
data.tar.gz: 61f1933acdbe068c5d47addd158ee35ea1e104058142ca5e9740756680d91ee819dc266219d2c4251446a8a6627ac900ee67943e1b442b11f2ecb8fe803c6da4
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require './lib/
|
1
|
+
require './lib/hashed_attr/version'
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'hashed_attr'
|
5
|
-
spec.version =
|
5
|
+
spec.version = HashedAttr::VERSION
|
6
6
|
spec.authors = ['Dann Luciano']
|
7
7
|
spec.email = ['dannluciano@gmail.com']
|
8
8
|
spec.summary = 'Hash attributes using SHA512 (or your custom hash strategy). Works with and without ActiveRecord.'
|
data/lib/hashed_attr.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module HashedAttr
|
4
|
+
require 'hashed_attr/version'
|
5
|
+
require 'hashed_attr/encryptor'
|
6
|
+
require 'hashed_attr/base'
|
7
|
+
require 'hashed_attr/active_record' if defined?(ActiveRecord)
|
8
|
+
|
9
|
+
class << self
|
10
|
+
extend Forwardable
|
11
|
+
def_delegators Base, :encryptor, :encryptor=
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.included(target)
|
15
|
+
target.send :include, Base
|
16
|
+
end
|
17
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module HashedAttr
|
2
2
|
module Base
|
3
3
|
def self.included(target)
|
4
4
|
target.extend(ClassMethods)
|
@@ -6,24 +6,24 @@ module HashAttr
|
|
6
6
|
|
7
7
|
class << self
|
8
8
|
# Define the object that will encrypt/decrypt values.
|
9
|
-
# By default, it's
|
9
|
+
# By default, it's HashedAttr::Encryptor
|
10
10
|
attr_accessor :encryptor
|
11
11
|
end
|
12
12
|
|
13
13
|
# Set initial encryptor engine.
|
14
|
-
self.encryptor = Encryptor
|
14
|
+
self.encryptor = HashedAttr::Encryptor
|
15
15
|
|
16
16
|
module ClassMethods
|
17
|
-
def
|
17
|
+
def hashed_attr(*args)
|
18
18
|
|
19
19
|
args.each do |attribute|
|
20
|
-
|
20
|
+
define_hashed_attribute(attribute)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
def
|
26
|
+
def define_hashed_attribute(attribute)
|
27
27
|
define_method attribute do
|
28
28
|
instance_variable_get("@#{attribute}")
|
29
29
|
end
|
@@ -31,7 +31,7 @@ module HashAttr
|
|
31
31
|
define_method "#{attribute}=" do |value|
|
32
32
|
instance_variable_set("@#{attribute}", value)
|
33
33
|
send("hashed_#{attribute}=", nil)
|
34
|
-
send("hashed_#{attribute}=",
|
34
|
+
send("hashed_#{attribute}=", HashedAttr.encryptor.encrypt(value)) if value
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashed_attr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dann Luciano
|
@@ -124,12 +124,12 @@ files:
|
|
124
124
|
- LICENSE.txt
|
125
125
|
- README.md
|
126
126
|
- Rakefile
|
127
|
-
-
|
128
|
-
- lib/
|
129
|
-
- lib/
|
130
|
-
- lib/
|
131
|
-
- lib/
|
132
|
-
- lib/
|
127
|
+
- hashed_attr.gemspec
|
128
|
+
- lib/hashed_attr.rb
|
129
|
+
- lib/hashed_attr/active_record.rb
|
130
|
+
- lib/hashed_attr/base.rb
|
131
|
+
- lib/hashed_attr/encryptor.rb
|
132
|
+
- lib/hashed_attr/version.rb
|
133
133
|
homepage: http://rubygems.org/gems/hashed_attr
|
134
134
|
licenses:
|
135
135
|
- MIT
|
data/lib/hash_attr.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module HashAttr
|
4
|
-
require 'hash_attr/version'
|
5
|
-
require 'hash_attr/encryptor'
|
6
|
-
require 'hash_attr/base'
|
7
|
-
require 'hash_attr/active_record' if defined?(ActiveRecord)
|
8
|
-
|
9
|
-
class << self
|
10
|
-
extend Forwardable
|
11
|
-
def_delegators Base, :encryptor, :encryptor=
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.included(target)
|
15
|
-
target.send :include, Base
|
16
|
-
end
|
17
|
-
end
|
data/lib/hash_attr/version.rb
DELETED