devision 0.0.3.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd090111f5536f1e83791e094c6ffd0adfaa1b2b
4
- data.tar.gz: f5bf06418c04f80db8434df86060605a417bd7ec
3
+ metadata.gz: 5b67a4a3a9fb587985deea0a44ba3001f02a2509
4
+ data.tar.gz: 8c7db59781cc595d064d92389276158eca7a7e20
5
5
  SHA512:
6
- metadata.gz: bd306bdba8dc69dceb93c2a83f91f14aa51ba36ed3c128c98ff54282845c68d2d3233804b38dcbea6efaa390de888f0a5ab582a9954ef0b1c18c2bc498540797
7
- data.tar.gz: ee71eef39446d81a33496954ea848cf743fc0109e2f325aa7df4cf2d6fd4f370ee4a3e5e00bf964f5ea0f3c5171eb88de69dd31122f4630adcd5005ac621d913
6
+ metadata.gz: cb8b1c9c8793494dc4c90f800cf79ec952dcc29405b398b38f34dea83b60155cf9e516bd770d4f346cca3c3b8eb2c5dd749123779e5d89140f6e6576cd5f47d9
7
+ data.tar.gz: bb7d9ebc5a36fb77d2387d81c665d44932a63cc682c5f5e8c759396b70f7fda84ce44dbb932259967a5b546662e30ea066d2a803f024f3b3849d9cd809bea854
@@ -0,0 +1,46 @@
1
+ module Devision
2
+ module Models
3
+ module Tokenizable
4
+ extend ActiveSupport::Concern
5
+
6
+ # Fields required on the target Model
7
+ def self.required_fields(klass)
8
+ [:token]
9
+ end
10
+
11
+ included do
12
+
13
+ attr_reader :raw_token
14
+
15
+ def generate_tokens
16
+ raw, enc = Devision.token_generator.generate(self.class, :token)
17
+ @raw_token = raw
18
+ self.token = enc
19
+ end
20
+
21
+ def generate_tokens!
22
+ generate_tokens && save(validate: false)
23
+ end
24
+
25
+ def clear_token
26
+ @raw_token = nil
27
+ self.token = nil
28
+ end
29
+
30
+ end
31
+
32
+ module ClassMethods
33
+
34
+ def locate_record_by_token(original_raw_token)
35
+ original_token = original_raw_token
36
+ saved_token = Devision.token_generator.digest(self, :token, original_token)
37
+
38
+ tokenizable = find_or_initialize_with_error_by(:token, saved_token)
39
+ tokenizable
40
+ end
41
+ end
42
+
43
+
44
+ end # Tokenizable
45
+ end # Models
46
+ end # Devision
@@ -7,8 +7,8 @@ module Devision
7
7
 
8
8
  MAJOR = 0
9
9
  MINOR = 0
10
- PATCH = 3
11
- PRE = 1
10
+ PATCH = 4
11
+ PRE = nil
12
12
 
13
13
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
14
14
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devision
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Faucett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-05 00:00:00.000000000 Z
11
+ date: 2014-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -142,6 +142,7 @@ files:
142
142
  - lib/devision/models/lockable.rb
143
143
  - lib/devision/models/recoverable.rb
144
144
  - lib/devision/models/rememberable.rb
145
+ - lib/devision/models/tokenizable.rb
145
146
  - lib/devision/models/validatable.rb
146
147
  - lib/devision/token_generator.rb
147
148
  - lib/devision/version.rb