jt-rails-tokenizable 1.1.2 → 1.2.0

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: 580b1426acc71098c588dfb41a8327ce51cd8607
4
- data.tar.gz: 0fc759cd640cfa69119286695d40fa6e40c14d4c
3
+ metadata.gz: 151a9e0db560d6792a31e425f1ce852768aa8636
4
+ data.tar.gz: bd936823c16acaa7fd2a2eb3775d201cddbb6362
5
5
  SHA512:
6
- metadata.gz: 80b815095b257ab63e90b5c776f28e59bffc81615a8f95279db368e150efb60ae263c25c4c2a9832eb5821517485012e13b45ad152141fb972a2efa9844b06c2
7
- data.tar.gz: c916f90730af2a98155040a627ce1de2f96b5d552f2fd01aab07982028dfe17faf2156f09b44089d57aa92972f8aa83a5f1366097b0cbcba311f1ff7fc61cf40
6
+ metadata.gz: 47b3f78f2135ce0fd58946ef0778111cb1275d95ed29350f479ec0f455c3a13826de903f0fe4d11c835c4b29754d677a2c96bb8e4aa477baffccb4fc9fadf6ba
7
+ data.tar.gz: 9ab91a6d14206824194209af203237d4f147f0ca2e40b3aaf769fa896ae937069ddb2cf6db6021bcc7dcbb629571f6b653947ac618946e0cf336ab64941196ba
@@ -3,7 +3,7 @@ Gem::Specification.new do |s|
3
3
  s.summary = "Token generation for ActiveRecord models in Ruby On Rails"
4
4
  s.description = "Generate tokens for ActiveRecord models in Ruby On Rails"
5
5
  s.homepage = 'https://github.com/jonathantribouharet/jt-rails-tokenizable'
6
- s.version = '1.1.2'
6
+ s.version = '1.2.0'
7
7
  s.files = `git ls-files`.split("\n")
8
8
  s.require_paths = ['lib']
9
9
  s.authors = ['Jonathan TRIBOUHARET']
data/lib/tokenize.rb CHANGED
@@ -2,7 +2,7 @@ module JT::Rails::Tokenizable::Tokenize
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do |base|
5
- before_validation :jt_rails_generate_tokens, on: :create
5
+ before_validation :jt_rails_generate_tokens_if_missing, on: :create
6
6
 
7
7
  base.class_eval do
8
8
 
@@ -27,6 +27,12 @@ module JT::Rails::Tokenizable::Tokenize
27
27
 
28
28
  end
29
29
 
30
+ def jt_rails_generate_tokens_if_missing
31
+ for field in self.class.jt_rails_token_fields.keys
32
+ generate_new_token(field) if self[field.to_sym].blank?
33
+ end
34
+ end
35
+
30
36
  def jt_rails_generate_tokens
31
37
  for field in self.class.jt_rails_token_fields.keys
32
38
  generate_new_token(field)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jt-rails-tokenizable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan TRIBOUHARET
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generate tokens for ActiveRecord models in Ruby On Rails
14
14
  email: jonathan.tribouharet@gmail.com
@@ -43,7 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
43
43
  version: '0'
44
44
  requirements: []
45
45
  rubyforge_project:
46
- rubygems_version: 2.0.14
46
+ rubygems_version: 2.0.14.1
47
47
  signing_key:
48
48
  specification_version: 4
49
49
  summary: Token generation for ActiveRecord models in Ruby On Rails