token_for 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/token_for/version.rb +1 -1
- data/lib/token_for.rb +3 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea38a9572684f9ec82abbe2e849f2f88134f554d
|
4
|
+
data.tar.gz: 2af85fc337cc23aad4148fc63f675408626a6159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94675e47f3614ae8652916e0348997e4aae6751cb83b8cb8c07353d02b82fced76c5b6b345871858a55216ef90ba2be856c1e8eb12664011fb4ac01ce3154b94
|
7
|
+
data.tar.gz: 08b3bbf807997c361eddbcdd34bc0f4b58b6fb95d934b54825cd77612ff01e5e6316ee95fdb5da7e2768dd0df1dc31cff681064fd16c7a94d3eaec25daef0ebf
|
data/lib/token_for/version.rb
CHANGED
data/lib/token_for.rb
CHANGED
@@ -5,13 +5,14 @@ module TokenFor
|
|
5
5
|
|
6
6
|
module ClassMethods
|
7
7
|
|
8
|
-
def token_for subject,
|
8
|
+
def token_for subject, attrs: [], expires_in: nil
|
9
9
|
|
10
10
|
# A method for generating the token
|
11
11
|
define_method("#{subject}_token") do
|
12
12
|
verifier = self.class.verifier_for(subject)
|
13
13
|
attr_hash = {} # The attributes need to be in a hash
|
14
|
-
|
14
|
+
binding.pry
|
15
|
+
attrs.map { |a| attr_hash.merge! a.to_sym => self.read_attribute(a) }
|
15
16
|
attr_hash.merge!(expires_on: Time.zone.now + expires_in) if expires_in
|
16
17
|
# Generate based on actual values of attributes.
|
17
18
|
verifier.generate(attr_hash)
|