default_value_for 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.asc ADDED
@@ -0,0 +1,8 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
3
+ Comment: GPGTools - http://gpgtools.org
4
+
5
+ iEYEABECAAYFAlE+JZIACgkQBqExCUtvQzKZNQCeLvjnoUT02T/dfONyAbxlBYxB
6
+ WtIAoMhBVIaPQGjNISUULE3ywwcPjBlB
7
+ =IM4Y
8
+ -----END PGP SIGNATURE-----
data/README.rdoc CHANGED
@@ -26,6 +26,10 @@ Add it to your Gemfile:
26
26
 
27
27
  gem "default_value_for"
28
28
 
29
+ This gem is signed using PGP with the Phusion Software Signing key: http://www.phusion.nl/about/gpg. That key in turn is signed by the rubygems-openpgp Certificate Authority: http://www.rubygems-openpgp-ca.org/.
30
+
31
+ You can verify the authenticity of the gem by following The Complete Guide to Verifying Gems with rubygems-openpgp: http://www.rubygems-openpgp-ca.org/blog/the-complete-guide-to-verifying-gems-with-rubygems-openpgp.html
32
+
29
33
  === Rails 2
30
34
 
31
35
  default_value_for no longer supports Rails 2! The last version that supported Rails
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{default_value_for}
3
- s.version = "2.0.1"
3
+ s.version = "2.0.2"
4
4
  s.summary = %q{Provides a way to specify default values for ActiveRecord models}
5
5
  s.description = %q{The default_value_for plugin allows one to define default values for ActiveRecord models in a declarative manner}
6
- s.email = %q{info@phusion.nl}
7
- s.homepage = %q{http://github.com/FooBarWidget/default_value_for}
6
+ s.email = %q{software-signing@phusion.nl}
7
+ s.homepage = %q{https://github.com/FooBarWidget/default_value_for}
8
8
  s.authors = ["Hongli Lai"]
9
9
  s.files = ['default_value_for.gemspec',
10
10
  'LICENSE.TXT', 'Rakefile', 'README.rdoc', 'test.rb',
@@ -58,12 +58,12 @@ module DefaultValueFor
58
58
  def default_value_for(attribute, options = {}, &block)
59
59
  value = options.is_a?(Hash) && options.stringify_keys.has_key?('value') ? options.stringify_keys['value'] : options
60
60
  allows_nil = options.is_a?(Hash) && options.stringify_keys.has_key?('allows_nil') ? options.stringify_keys['allows_nil'] : true
61
-
61
+
62
62
  if !method_defined?(:set_default_values)
63
63
  include(InstanceMethods)
64
64
 
65
65
  after_initialize :set_default_values
66
-
66
+
67
67
  if respond_to?(:class_attribute)
68
68
  class_attribute :_default_attribute_values
69
69
  class_attribute :_default_attribute_values_not_allowing_nil
@@ -71,7 +71,7 @@ module DefaultValueFor
71
71
  class_inheritable_accessor :_default_attribute_values
72
72
  class_inheritable_accessor :_default_attribute_values_not_allowing_nil
73
73
  end
74
-
74
+
75
75
  extend(DelayedClassMethods)
76
76
  init_hash = true
77
77
  else
@@ -94,9 +94,9 @@ module DefaultValueFor
94
94
  def default_values(values)
95
95
  values.each_pair do |key, options|
96
96
  options = options.stringify_keys if options.is_a?(Hash)
97
-
97
+
98
98
  value = options.is_a?(Hash) && options.has_key?('value') ? options['value'] : options
99
-
99
+
100
100
  if value.kind_of? Proc
101
101
  default_value_for(key, options.is_a?(Hash) ? options : {}, &value)
102
102
  else
@@ -111,7 +111,7 @@ module DefaultValueFor
111
111
  return _default_attribute_values unless superclass.respond_to?(:_default_attribute_values)
112
112
  superclass._all_default_attribute_values.merge(_default_attribute_values)
113
113
  end
114
-
114
+
115
115
  def _all_default_attribute_values_not_allowing_nil
116
116
  return _default_attribute_values_not_allowing_nil unless superclass.respond_to?(:_default_attribute_values_not_allowing_nil)
117
117
  result = superclass._all_default_attribute_values_not_allowing_nil.concat(_default_attribute_values_not_allowing_nil)
@@ -123,35 +123,35 @@ module DefaultValueFor
123
123
  module InstanceMethods
124
124
  def initialize(attributes = nil, options = {})
125
125
  @initialization_attributes = attributes.is_a?(Hash) ? attributes.stringify_keys : {}
126
-
126
+
127
127
  unless options[:without_protection]
128
- if respond_to?(:mass_assignment_options) && options.has_key?(:as)
128
+ if respond_to?(:mass_assignment_options, true) && options.has_key?(:as)
129
129
  @initialization_attributes = sanitize_for_mass_assignment(@initialization_attributes, options[:as])
130
- elsif respond_to?(:sanitize_for_mass_assignment)
130
+ elsif respond_to?(:sanitize_for_mass_assignment, true)
131
131
  @initialization_attributes = sanitize_for_mass_assignment(@initialization_attributes)
132
132
  else
133
133
  @initialization_attributes = remove_attributes_protected_from_mass_assignment(@initialization_attributes)
134
134
  end
135
135
  end
136
-
136
+
137
137
  if ActiveRecord::VERSION::MAJOR > 3 || (ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR > 0)
138
138
  super(attributes, options)
139
139
  else
140
140
  super(attributes)
141
141
  end
142
142
  end
143
-
143
+
144
144
  def set_default_values
145
145
  self.class._all_default_attribute_values.each do |attribute, container|
146
146
  next unless self.new_record? || self.class._all_default_attribute_values_not_allowing_nil.include?(attribute)
147
-
147
+
148
148
  connection_default_value_defined = new_record? && respond_to?("#{attribute}_changed?") && !__send__("#{attribute}_changed?")
149
-
149
+
150
150
  next unless connection_default_value_defined || self.attributes[attribute].blank?
151
-
151
+
152
152
  # allow explicitly setting nil through allow nil option
153
153
  next if @initialization_attributes.is_a?(Hash) && @initialization_attributes.has_key?(attribute) && !self.class._all_default_attribute_values_not_allowing_nil.include?(attribute)
154
-
154
+
155
155
  __send__("#{attribute}=", container.evaluate(self))
156
156
  changed_attributes.delete(attribute)
157
157
  end
metadata CHANGED
@@ -1,32 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: default_value_for
3
- version: !ruby/object:Gem::Version
4
- hash: 13
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.2
5
5
  prerelease:
6
- segments:
7
- - 2
8
- - 0
9
- - 1
10
- version: 2.0.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Hongli Lai
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-06-04 00:00:00 Z
12
+ date: 2013-03-11 00:00:00.000000000 Z
19
13
  dependencies: []
20
-
21
- description: The default_value_for plugin allows one to define default values for ActiveRecord models in a declarative manner
22
- email: info@phusion.nl
14
+ description: The default_value_for plugin allows one to define default values for
15
+ ActiveRecord models in a declarative manner
16
+ email: software-signing@phusion.nl
23
17
  executables: []
24
-
25
18
  extensions: []
26
-
27
19
  extra_rdoc_files: []
28
-
29
- files:
20
+ files:
30
21
  - default_value_for.gemspec
31
22
  - LICENSE.TXT
32
23
  - Rakefile
@@ -35,39 +26,28 @@ files:
35
26
  - init.rb
36
27
  - lib/default_value_for.rb
37
28
  - lib/default_value_for/railtie.rb
38
- homepage: http://github.com/FooBarWidget/default_value_for
29
+ homepage: https://github.com/FooBarWidget/default_value_for
39
30
  licenses: []
40
-
41
31
  post_install_message:
42
32
  rdoc_options: []
43
-
44
- require_paths:
33
+ require_paths:
45
34
  - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
35
+ required_ruby_version: !ruby/object:Gem::Requirement
47
36
  none: false
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- hash: 3
52
- segments:
53
- - 0
54
- version: "0"
55
- required_rubygems_version: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
42
  none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 0
63
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
64
47
  requirements: []
65
-
66
48
  rubyforge_project:
67
- rubygems_version: 1.8.15
49
+ rubygems_version: 1.8.25
68
50
  signing_key:
69
51
  specification_version: 3
70
52
  summary: Provides a way to specify default values for ActiveRecord models
71
53
  test_files: []
72
-
73
- has_rdoc:
metadata.gz.asc ADDED
@@ -0,0 +1,8 @@
1
+ -----BEGIN PGP SIGNATURE-----
2
+ Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
3
+ Comment: GPGTools - http://gpgtools.org
4
+
5
+ iEYEABECAAYFAlE+JZIACgkQBqExCUtvQzI2lACeOOSQm6qs6cUbE1wAEuYG9e7O
6
+ G94An31jkRlGHJLznE+aimoQv+Bg5w7k
7
+ =HdjK
8
+ -----END PGP SIGNATURE-----