default_value_for 2.0.0 → 2.0.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.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{default_value_for}
3
- s.version = "2.0.0"
3
+ s.version = "2.0.1"
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
6
  s.email = %q{info@phusion.nl}
@@ -74,8 +74,11 @@ module DefaultValueFor
74
74
 
75
75
  extend(DelayedClassMethods)
76
76
  init_hash = true
77
+ else
78
+ methods = singleton_methods(false)
79
+ init_hash = !methods.include?("_default_attribute_values") && !methods.include?(:_default_attribute_values)
77
80
  end
78
- if init_hash || !singleton_methods(false).to_s.include?("_default_attribute_values")
81
+ if init_hash
79
82
  self._default_attribute_values = ActiveSupport::OrderedHash.new
80
83
  self._default_attribute_values_not_allowing_nil = []
81
84
  end
@@ -111,7 +114,9 @@ module DefaultValueFor
111
114
 
112
115
  def _all_default_attribute_values_not_allowing_nil
113
116
  return _default_attribute_values_not_allowing_nil unless superclass.respond_to?(:_default_attribute_values_not_allowing_nil)
114
- superclass._all_default_attribute_values_not_allowing_nil.merge(_default_attribute_values_not_allowing_nil)
117
+ result = superclass._all_default_attribute_values_not_allowing_nil.concat(_default_attribute_values_not_allowing_nil)
118
+ result.uniq!
119
+ result
115
120
  end
116
121
  end
117
122
 
data/test.rb CHANGED
@@ -424,4 +424,13 @@ class DefaultValuePluginTest < Test::Unit::TestCase
424
424
  object = TestClass.new(options)
425
425
  assert_equal(options_dup, options)
426
426
  end
427
+
428
+ def test_subclass_find
429
+ define_model_class do
430
+ default_value_for :number, 5678
431
+ end
432
+ define_model_class("SpecialNumber", "TestClass")
433
+ n = SpecialNumber.create
434
+ assert_nothing_raised { SpecialNumber.find(n.id) }
435
+ end
427
436
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: default_value_for
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 0
10
- version: 2.0.0
9
+ - 1
10
+ version: 2.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Hongli Lai
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-27 00:00:00 Z
18
+ date: 2012-06-04 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: The default_value_for plugin allows one to define default values for ActiveRecord models in a declarative manner