has_token 0.4.0 → 0.4.1

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/has_token.gemspec +1 -1
  3. data/lib/has_token.rb +5 -7
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{has_token}
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["laserlemon"]
@@ -15,7 +15,8 @@ module HasToken
15
15
  :characters => [('a'..'z'), ('A'..'Z'), ('0'..'9')].map(&:to_a).sum,
16
16
  :constructor => proc(&:generate_token),
17
17
  :to_param => false,
18
- :readonly => true
18
+ :readonly => true,
19
+ :dependent => :nullify
19
20
  )
20
21
 
21
22
  class_inheritable_accessor :has_token_options
@@ -23,10 +24,9 @@ module HasToken
23
24
  self.has_token_options = options
24
25
 
25
26
  if options[:to_param]
26
- def to_param_with_token
27
+ define_method(:to_param_with_token) do
27
28
  read_attribute(options[:column])
28
29
  end
29
-
30
30
  alias_method_chain :to_param, :token
31
31
  end
32
32
 
@@ -34,7 +34,7 @@ module HasToken
34
34
  attr_readonly(options[:column])
35
35
  end
36
36
 
37
- has_one :global_token, :class_name => 'Token', :as => :parent, :dependent => :nullify
37
+ has_one :global_token, :class_name => 'Token', :as => :parent, :dependent => options[:dependent]
38
38
 
39
39
  include InstanceMethods
40
40
 
@@ -50,9 +50,7 @@ module HasToken
50
50
 
51
51
  def create_token
52
52
  column = has_token_options[:column]
53
- value = read_attribute(column)
54
-
55
- if value
53
+ if value = read_attribute(column)
56
54
  token = build_global_token(:value => value)
57
55
  unless token.save
58
56
  errors.add(column, token.errors.on(:value))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_token
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - laserlemon