CHANGELOG.md 8.8 KB
Newer Older
1 2
## Rails 4.0.0 (unreleased) ##

3 4 5 6 7 8 9 10 11 12 13
*   Hash#extract! returns only those keys that present in the reciever.

        {:a => 1, :b => 2}.extract!(:a, :x) # => {:a => 1}

    *Mikhail Dieterle*

*   Hash#extract! returns the same subclass, that the reciever is. I.e.
    HashWithIndifferentAccess#extract! returns HashWithIndifferentAccess instance.

    *Mikhail Dieterle*

14 15
*   Optimize ActiveSupport::Cache::Entry to reduce memory and processing overhead. *Brian Durand*

16 17 18 19 20 21 22
*   Tests tag the Rails log with the current test class and test case:

        [SessionsControllerTest] [test_0002_sign in] Processing by SessionsController#create as HTML
        [SessionsControllerTest] [test_0002_sign in] ...

    *Jeremy Kemper*

23 24 25 26 27 28 29 30 31 32 33 34 35 36
*   Add logger.push_tags and .pop_tags to complement logger.tagged:

        class Job
          def before
            Rails.logger.push_tags :jobs, self.class.name
          end

          def after
            Rails.logger.pop_tags 2
          end
        end

    *Jeremy Kemper*

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
*   Allow delegation to the class using the `:class` keyword, replacing
    `self.class` usage:

        class User
          def self.hello
           "world"
          end

          delegate :hello, to: :class
        end

    *Marc-Andre Lafortune*

*   `Date.beginning_of_week` thread local and `beginning_of_week` application
    config option added (default is Monday).

    *Innokenty Mikhailov*
54

55 56 57 58 59 60 61 62 63 64 65 66 67
*   An optional block can be passed to `config_accessor` to set its default value

        class User
          include ActiveSupport::Configurable
          config_accessor :hair_colors do
            [:brown, :black, :blonde, :red]
          end
        end

        User.hair_colors # => [:brown, :black, :blonde, :red]

    *Larry Lv*

68
*   ActiveSupport::Benchmarkable#silence has been deprecated due to its lack of
69 70 71 72 73 74
    thread safety. It will be removed without replacement in Rails 4.1.

    *Steve Klabnik*

*   An optional block can be passed to `Hash#deep_merge`. The block will be invoked
    for each duplicated key and used to resolve the conflict.
75

76
    *Pranas Kiziela*
77

78 79 80 81 82
*   ActiveSupport::Deprecation is now a class. It is possible to create an instance
    of deprecator. Backwards compatibility has been preserved.

    You can choose which instance of the deprecator will be used.

83
        deprecate :method_name, :deprecator => deprecator_instance
84 85 86

    You can use ActiveSupport::Deprecation in your gem.

87 88
        require 'active_support/deprecation'
        require 'active_support/core_ext/module/deprecation'
89

90 91 92 93
        class MyGem
          def self.deprecator
            ActiveSupport::Deprecation.new('2.0', 'MyGem')
          end
94

95 96
          def old_method
          end
97

98 99
          def new_method
          end
100

101 102
          deprecate :old_method => :new_method, :deprecator => deprecator
        end
103

104 105
        MyGem.new.old_method
        # => DEPRECATION WARNING: old_method is deprecated and will be removed from MyGem 2.0 (use new_method instead). (called from <main> at file.rb:18)
106 107 108

    *Piotr Niełacny & Robert Pankowecki*

109 110
*   `ERB::Util.html_escape` encodes single quote as `#39`. Decimal form has better support in old browsers. *Kalys Osmonov*

111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
*   `ActiveSupport::Callbacks`: deprecate monkey patch of object callbacks.
    Using the #filter method like this:

        before_filter MyFilter.new

        class MyFilter
          def filter(controller)
          end
        end

    Is now deprecated with recommendation to use the corresponding filter type
    (`#before`, `#after` or `#around`):

        before_filter MyFilter.new

        class MyFilter
          def before(controller)
          end
        end

    *Bogdan Gusiev*

133 134 135 136 137 138
*   An optional block can be passed to `HashWithIndifferentAccess#update` and `#merge`.
    The block will be invoked for each duplicated key, and used to resolve the conflict,
    thus replicating the behaviour of the corresponding methods on the `Hash` class.

    *Leo Cassarani*

139 140 141 142 143 144
*   Remove `j` alias for `ERB::Util#json_escape`.
    The `j` alias is already used for `ActionView::Helpers::JavaScriptHelper#escape_javascript`
    and both modules are included in the view context that would confuse the developers.

    *Akira Matsuda*

145 146 147 148
*   Replace deprecated `memcache-client` gem with `dalli` in ActiveSupport::Cache::MemCacheStore

    *Guillermo Iguaran*

149 150 151 152 153
*   Add default values to all `ActiveSupport::NumberHelper` methods, to avoid
    errors with empty locales or missing values.

    *Carlos Antonio da Silva*

154 155
*   `ActiveSupport::JSON::Variable` is deprecated. Define your own `#as_json` and
    `#encode_json` methods for custom JSON string literals.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171

    *Erich Menge*

*   Add String#indent. *fxn & Ace Suares*

*   Inflections can now be defined per locale. `singularize` and `pluralize`
    accept locale as an extra argument.

    *David Celis*

*   `Object#try` will now return nil instead of raise a NoMethodError if the
    receiving object does not implement the method, but you can still get the
    old behavior by using the new `Object#try!`.

    *DHH*

M
Mark Turner 已提交
172
*   `ERB::Util.html_escape` now escapes single quotes. *Santiago Pastorino*
173

174
*   `Time#change` now works with time values with offsets other than UTC or the local time zone. *Andrew White*
175

176
*   `ActiveSupport::Callbacks`: deprecate usage of filter object with `#before` and `#after` methods as `around` callback. *Bogdan Gusiev*
177

178
*   Add `Time#prev_quarter` and `Time#next_quarter` short-hands for `months_ago(3)` and `months_since(3)`. *SungHee Kang*
179

180 181
*   Remove obsolete and unused `require_association` method from dependencies. *fxn*

182 183 184 185 186 187 188 189 190 191 192 193
*   Add `:instance_accessor` option for `config_accessor`.

        class User
          include ActiveSupport::Configurable
          config_accessor :allowed_access, instance_accessor: false
        end

        User.new.allowed_access = true # => NoMethodError
        User.new.allowed_access        # => NoMethodError

    *Francesco Rodriguez*

194 195
*   ActionView::Helpers::NumberHelper methods have been moved to ActiveSupport::NumberHelper and are now available via
    Numeric#to_s.  Numeric#to_s now accepts the formatting  options :phone, :currency, :percentage, :delimited,
196 197
    :rounded, :human, and :human_size. *Andrew Mutz*

198
*   Add `Hash#transform_keys`, `Hash#transform_keys!`, `Hash#deep_transform_keys`, and `Hash#deep_transform_keys!`. *Mark McSpadden*
199

200
*   Changed xml type `datetime` to `dateTime` (with upper case letter `T`). *Angelo Capilleri*
201

202 203
*   Add `:instance_accessor` option for `class_attribute`. *Alexey Vakhov*

204 205
*   `constantize` now looks in the ancestor chain. *Marc-Andre Lafortune & Andrew White*

206 207 208 209
*   Adds `Hash#deep_stringify_keys` and `Hash#deep_stringify_keys!` to convert all keys from a +Hash+ instance into strings *Lucas Húngaro*

*   Adds `Hash#deep_symbolize_keys` and `Hash#deep_symbolize_keys!` to convert all keys from a +Hash+ instance into symbols *Lucas Húngaro*

210
*   `Object#try` can't call private methods. *Vasiliy Ermolovich*
211

212 213
*   `AS::Callbacks#run_callbacks` remove `key` argument. *Francesco Rodriguez*

214
*   `deep_dup` works more expectedly now and duplicates also values in +Hash+ instances and elements in +Array+ instances. *Alexey Gaziev*
215

216
*   Inflector no longer applies ice -> ouse to words like slice, police, ets *Wes Morgan*
J
José Valim 已提交
217

218
*   Add `ActiveSupport::Deprecations.behavior = :silence` to completely ignore Rails runtime deprecations *twinturbo*
219

220
*   Make Module#delegate stop using `send` - can no longer delegate to private methods. *dasch*
D
Daniel Schierbeck 已提交
221

222
*   AS::Callbacks: deprecate `:rescuable` option. *Bogdan Gusiev*
223

224
*   Adds Integer#ordinal to get the ordinal suffix string of an integer. *Tim Gildea*
225

226
*   AS::Callbacks: `:per_key` option is no longer supported
227

228
*   `AS::Callbacks#define_callbacks`: add `:skip_after_callbacks_if_terminated` option.
229

230
*   Add html_escape_once to ERB::Util, and delegate escape_once tag helper to it. *Carlos Antonio da Silva*
231

232
*   Remove ActiveSupport::TestCase#pending method, use `skip` instead. *Carlos Antonio da Silva*
233

234 235
*   Deprecates the compatibility method Module#local_constant_names,
    use Module#local_constants instead (which returns symbols). *fxn*
236

237 238
*   Deletes the compatibility method Module#method_names,
    use Module#methods from now on (which returns symbols). *fxn*
239

240 241
*   Deletes the compatibility method Module#instance_method_names,
    use Module#instance_methods from now on (which returns symbols). *fxn*
242

243 244
*   BufferedLogger is deprecated.  Use ActiveSupport::Logger, or the logger
    from Ruby stdlib.
245

246
*   Unicode database updated to 6.1.0.
247

248 249
*   Adds `encode_big_decimal_as_string` option to force JSON serialization of BigDecimals as numeric instead
    of wrapping them in strings for safety.
250

251 252
*   Remove deprecated ActiveSupport::JSON::Variable. *Erich Menge*

253 254
*   Optimize log subscribers to check log level before doing any processing. *Brian Durand*

X
Xavier Noria 已提交
255
Please check [3-2-stable](https://github.com/rails/rails/blob/3-2-stable/activesupport/CHANGELOG.md) for previous changes.