activemodel 3.0.5 → 3.0.6.rc1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,22 @@
1
+ *Rails 3.0.6 (unreleased)*
2
+
3
+ * Fix when database column name has some symbolic characters (e.g. Oracle CASE# VARCHAR2(20)) #5818 #6850 [Robert Pankowecki, Santiago Pastorino]
4
+
5
+ * Fix length validation for fixnums #6556 [Andriy Tyurnikov]
6
+
7
+ * Fix i18n key collision with namespaced models #6448 [yves.senn]
8
+
9
+
10
+ *Rails 3.0.5 (February 26, 2011)*
11
+
12
+ * No changes.
13
+
14
+
15
+ *Rails 3.0.4 (February 8, 2011)*
16
+
17
+ * No changes.
18
+
19
+
1
20
  *Rails 3.0.3 (November 16, 2010)*
2
21
 
3
22
  * No changes.
@@ -93,19 +93,22 @@ module ActiveModel
93
93
  def define_attr_method(name, value=nil, &block)
94
94
  sing = singleton_class
95
95
  sing.class_eval <<-eorb, __FILE__, __LINE__ + 1
96
- if method_defined?(:original_#{name})
97
- undef :original_#{name}
96
+ if method_defined?(:'original_#{name}')
97
+ undef :'original_#{name}'
98
98
  end
99
- alias_method :original_#{name}, :#{name}
99
+ alias_method :'original_#{name}', :'#{name}'
100
100
  eorb
101
101
  if block_given?
102
102
  sing.send :define_method, name, &block
103
103
  else
104
- # use eval instead of a block to work around a memory leak in dev
105
- # mode in fcgi
106
- sing.class_eval <<-eorb, __FILE__, __LINE__ + 1
107
- def #{name}; #{value.to_s.inspect}; end
108
- eorb
104
+ if name =~ /^[a-zA-Z_]\w*[!?=]?$/
105
+ sing.class_eval <<-eorb, __FILE__, __LINE__ + 1
106
+ def #{name}; #{value.nil? ? 'nil' : value.to_s.inspect}; end
107
+ eorb
108
+ else
109
+ value = value.to_s if value
110
+ sing.send(:define_method, name) { value }
111
+ end
109
112
  end
110
113
  end
111
114
 
@@ -226,7 +229,7 @@ module ActiveModel
226
229
  attribute_method_matchers.each do |matcher|
227
230
  module_eval <<-STR, __FILE__, __LINE__ + 1
228
231
  def #{matcher.method_name(new_name)}(*args)
229
- send(:#{matcher.method_name(old_name)}, *args)
232
+ send(:'#{matcher.method_name(old_name)}', *args)
230
233
  end
231
234
  STR
232
235
  end
@@ -269,11 +272,11 @@ module ActiveModel
269
272
  method_name = matcher.method_name(attr_name)
270
273
 
271
274
  generated_attribute_methods.module_eval <<-STR, __FILE__, __LINE__ + 1
272
- if method_defined?(:#{method_name})
273
- undef :#{method_name}
275
+ if method_defined?(:'#{method_name}')
276
+ undef :'#{method_name}'
274
277
  end
275
- def #{method_name}(*args)
276
- send(:#{matcher.method_missing_target}, '#{attr_name}', *args)
278
+ define_method('#{method_name}') do |*args|
279
+ send(:'#{matcher.method_missing_target}', '#{attr_name}', *args)
277
280
  end
278
281
  STR
279
282
  end
@@ -295,8 +295,8 @@ module ActiveModel
295
295
  end
296
296
 
297
297
  defaults = @base.class.lookup_ancestors.map do |klass|
298
- [ :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.i18n_key}.attributes.#{attribute}.#{type}",
299
- :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.i18n_key}.#{type}" ]
298
+ [ :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.underscore}.attributes.#{attribute}.#{type}",
299
+ :"#{@base.class.i18n_scope}.errors.models.#{klass.model_name.underscore}.#{type}" ]
300
300
  end
301
301
 
302
302
  defaults << options.delete(:message)
@@ -2,7 +2,7 @@ require 'active_support/inflector'
2
2
 
3
3
  module ActiveModel
4
4
  class Name < String
5
- attr_reader :singular, :plural, :element, :collection, :partial_path, :i18n_key
5
+ attr_reader :singular, :plural, :element, :collection, :partial_path
6
6
  alias_method :cache_key, :collection
7
7
 
8
8
  def initialize(klass)
@@ -14,7 +14,6 @@ module ActiveModel
14
14
  @human = ActiveSupport::Inflector.humanize(@element).freeze
15
15
  @collection = ActiveSupport::Inflector.tableize(self).freeze
16
16
  @partial_path = "#{@collection}/#{@element}".freeze
17
- @i18n_key = ActiveSupport::Inflector.underscore(self).tr('/', '.').to_sym
18
17
  end
19
18
 
20
19
  # Transform the model name into a more humane format, using I18n. By default,
@@ -28,7 +27,7 @@ module ActiveModel
28
27
  @klass.respond_to?(:i18n_scope)
29
28
 
30
29
  defaults = @klass.lookup_ancestors.map do |klass|
31
- klass.model_name.i18n_key
30
+ klass.model_name.underscore.to_sym
32
31
  end
33
32
 
34
33
  defaults << options.delete(:default) if options[:default]
@@ -52,9 +51,6 @@ module ActiveModel
52
51
  # BookCover.model_name # => "BookCover"
53
52
  # BookCover.model_name.human # => "Book cover"
54
53
  #
55
- # BookCover.model_name.i18n_key # => "book_cover"
56
- # BookModule::BookCover.model_name.i18n_key # => "book_module.book_cover"
57
- #
58
54
  # Providing the functionality that ActiveModel::Naming provides in your object
59
55
  # is required to pass the Active Model Lint test. So either extending the provided
60
56
  # method below, or rolling your own is required..
@@ -44,7 +44,7 @@ module ActiveModel
44
44
  # Specify +options+ with additional translating options.
45
45
  def human_attribute_name(attribute, options = {})
46
46
  defaults = lookup_ancestors.map do |klass|
47
- :"#{self.i18n_scope}.attributes.#{klass.model_name.i18n_key}.#{attribute}"
47
+ :"#{self.i18n_scope}.attributes.#{klass.model_name.underscore}.#{attribute}"
48
48
  end
49
49
 
50
50
  defaults << :"attributes.#{attribute}"
@@ -43,7 +43,8 @@ module ActiveModel
43
43
 
44
44
  value ||= [] if key == :maximum
45
45
 
46
- next if value && value.size.send(validity_check, check_value)
46
+ value_length = value.respond_to?(:length) ? value.length : value.to_s.length
47
+ next if value_length.send(validity_check, check_value)
47
48
 
48
49
  errors_options = options.except(*RESERVED_OPTIONS)
49
50
  errors_options[:count] = check_value
@@ -2,8 +2,8 @@ module ActiveModel
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 3
4
4
  MINOR = 0
5
- TINY = 5
6
- PRE = nil
5
+ TINY = 6
6
+ PRE = "rc1"
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
9
9
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease:
4
+ hash: 15424071
5
+ prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 0
9
- - 5
10
- version: 3.0.5
9
+ - 6
10
+ - rc
11
+ - 1
12
+ version: 3.0.6.rc1
11
13
  platform: ruby
12
14
  authors:
13
15
  - David Heinemeier Hansson
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2011-02-26 00:00:00 -08:00
20
+ date: 2011-03-29 00:00:00 -07:00
19
21
  default_executable:
20
22
  dependencies:
21
23
  - !ruby/object:Gem::Dependency
@@ -26,12 +28,14 @@ dependencies:
26
28
  requirements:
27
29
  - - "="
28
30
  - !ruby/object:Gem::Version
29
- hash: 13
31
+ hash: 15424071
30
32
  segments:
31
33
  - 3
32
34
  - 0
33
- - 5
34
- version: 3.0.5
35
+ - 6
36
+ - rc
37
+ - 1
38
+ version: 3.0.6.rc1
35
39
  type: :runtime
36
40
  version_requirements: *id001
37
41
  - !ruby/object:Gem::Dependency
@@ -58,11 +62,12 @@ dependencies:
58
62
  requirements:
59
63
  - - ~>
60
64
  - !ruby/object:Gem::Version
61
- hash: 3
65
+ hash: 11
62
66
  segments:
63
67
  - 0
64
- - 4
65
- version: "0.4"
68
+ - 5
69
+ - 0
70
+ version: 0.5.0
66
71
  type: :runtime
67
72
  version_requirements: *id003
68
73
  description: A toolkit for building modeling frameworks like Active Record and Active Resource. Rich support for attributes, callbacks, validations, observers, serialization, internationalization, and testing.
@@ -134,16 +139,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
134
139
  required_rubygems_version: !ruby/object:Gem::Requirement
135
140
  none: false
136
141
  requirements:
137
- - - ">="
142
+ - - ">"
138
143
  - !ruby/object:Gem::Version
139
- hash: 3
144
+ hash: 25
140
145
  segments:
141
- - 0
142
- version: "0"
146
+ - 1
147
+ - 3
148
+ - 1
149
+ version: 1.3.1
143
150
  requirements: []
144
151
 
145
152
  rubyforge_project: activemodel
146
- rubygems_version: 1.5.2
153
+ rubygems_version: 1.6.1
147
154
  signing_key:
148
155
  specification_version: 3
149
156
  summary: A toolkit for building modeling frameworks (part of Rails).