1. 04 1月, 2015 4 次提交
  2. 03 1月, 2015 6 次提交
    • R
      Fix a few typos [ci skip] · 9b9ec0de
      Robin Dupret 提交于
      9b9ec0de
    • C
      Add config to halt callback chain on return false · 9c65c539
      claudiob 提交于
      This stems from [a comment](rails#17227 (comment)) by @dhh.
      In summary:
      
      * New Rails 5.0 apps will not accept `return false` as a way to halt callback chains, and will not display a deprecation warning.
      * Existing apps ported to Rails 5.0 will still accept `return false` as a way to halt callback chains, albeit with a deprecation warning.
      
      For this purpose, this commit introduces a Rails configuration option:
      
      ```ruby
      config.active_support.halt_callback_chains_on_return_false
      ```
      
      For new Rails 5.0 apps, this option will be set to `false` by a new initializer
      `config/initializers/callback_terminator.rb`:
      
      ```ruby
      Rails.application.config.active_support.halt_callback_chains_on_return_false = false
      ```
      
      For existing apps ported to Rails 5.0, the initializers above will not exist.
      Even running `rake rails:update` will not create this initializer.
      
      Since the default value of `halt_callback_chains_on_return_false` is set to
      `true`, these apps will still accept `return true` as a way to halt callback
      chains, displaying a deprecation warning.
      
      Developers will be able to switch to the new behavior (and stop the warning)
      by manually adding the line above to their `config/application.rb`.
      
      A gist with the suggested release notes to add to Rails 5.0 after this
      commit is available at https://gist.github.com/claudiob/614c59409fb7d11f2931
      9c65c539
    • C
      Deprecate `false` as the way to halt AS callbacks · d217daf6
      claudiob 提交于
      After this commit, returning `false` in a callback will display a deprecation
      warning to make developers aware of the fact that they need to explicitly
      `throw(:abort)` if their intention is to halt a callback chain.
      
      This commit also patches two internal uses of AS::Callbacks (inside
      ActiveRecord and ActionDispatch) which sometimes return `false` but whose
      returned value is not meaningful for the purpose of execution.
      
      In both cases, the returned value is set to `true`, which does not affect the
      execution of the callbacks but prevents unrequested deprecation warnings from
      showing up.
      d217daf6
    • C
      Throw :abort halts default CallbackChains · 2386daab
      claudiob 提交于
      This commit changes arguments and default value of CallbackChain's :terminator
      option.
      
      After this commit, Chains of callbacks defined **without** an explicit
      `:terminator` option will be halted as soon as a `before_` callback throws
      `:abort`.
      
      Chains of callbacks defined **with** a `:terminator` option will maintain their
      existing behavior of halting as soon as a `before_` callback matches the
      terminator's expectation. For instance, ActiveModel's callbacks will still
      halt the chain when a `before_` callback returns `false`.
      2386daab
    • R
      Deprecate `MissingSourceFile` in favor of `LoadError`. · 734d97d2
      Rafael Mendonça França 提交于
      `MissingSourceFile` was just an alias to `LoadError` and was not
      being raised inside the framework.
      734d97d2
    • R
      Remove thread variables backport · 8b3cd74b
      Rafael Mendonça França 提交于
      They are already present on Ruby 2.2
      8b3cd74b
  3. 02 1月, 2015 3 次提交
  4. 31 12月, 2014 1 次提交
  5. 30 12月, 2014 1 次提交
  6. 29 12月, 2014 2 次提交
    • R
      54ec0cbf
    • V
      When trying to access a character on a string buffer object via `:[]`, if the... · 98367466
      Vipul A M 提交于
      When trying to access a character on a string buffer object via `:[]`, if the object being accessed currently returns `html_safe?` as true,
      we used to set  `@html_safe` variable as true on new object created. When doing something like
      
      x = 'Hello'.html_safe
      x[/a/, 1]
      
      would throw an error on ruby 2.2, since when nothign gets matched nil is returned by the code and it tries to set   `@html_safe` value to true,
      which would error since starting 2.2 nil is frozen.
      
      This change adds a safety net to avoid setting `@html_safe = true` on frozen objects.
      
      Fixes #18235
      98367466
  7. 27 12月, 2014 1 次提交
  8. 25 12月, 2014 1 次提交
  9. 22 12月, 2014 1 次提交
  10. 21 12月, 2014 1 次提交
  11. 19 12月, 2014 1 次提交
  12. 18 12月, 2014 6 次提交
  13. 17 12月, 2014 1 次提交
    • C
      Replace AS::TimeWithZone#since with alias to + · 05affb2c
      claudiob 提交于
      Stems from [Google group discussion](https://groups.google.com/forum/#!topic/rubyonrails-core/jSPbP-TNLb0).
      
      Currently `AS::TimeWithZone` has two methods to add an interval to a time:
      `+(other)` and `since(other)` ([docs](http://edgeapi.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html)).
      
      The two methods are "pretty much" equivalent in every case:
      
      1. When adding any interval to an `AS::TimeWithZone` representing a `Time`:
      
        ```ruby
        t = Time.now.in_time_zone       #=> Thu, 04 Dec 2014 18:56:28 EST -05:00
        t + 1 == t.since(1)             #=> true
        t + 1.day == t.since(1.day)     #=> true
        t + 1.month == t.since(1.month) #=> true
        ```
      
      2. When adding any interval to an `AS::TimeWithZone` representing a `Date`:
      
        ```ruby
        d = Date.today.in_time_zone     #=> Thu, 04 Dec 2014 00:00:00 EST -05:00
        d + 1 == d.since(1)             #=> true
        d + 1.day == d.since(1.day)     #=> true
        d + 1.month == d.since(1.month) #=> true
        ```
      
      3. When adding any interval to an `AS::TimeWithZone` representing a `DateTime`:
      
        ```ruby
        dt = DateTime.now.in_time_zone    #=> Thu, 04 Dec 2014 18:57:28 EST -05:00
        dt + 1 == dt.since(1)             #=> true
        dt + 1.day == dt.since(1.day)     #=> true
        dt + 1.month == dt.since(1.month) #=> false
        ```
      
      As you can see, the only case in which they differ is when the interval added
      to a `DateTime` is in a format like `1.month`.
      
      However, this usage of "since" is explicitly discouraged by the
      [documentation of `DateTime#since`](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/date_time/calculations.rb#L86L88):
      
      > Returns a new DateTime representing the time a number of seconds since the instance time.
      > Do not use this method in combination with x.months, use months_since instead!
      
      And indeed, following this recommendation the correct result is returned:
      
      ```ruby
      dt + 1.month == dt.months_since 1 #=> true
      ```
      
      Therefore, my proposal is to remove the method definition of `TimeWithZone#since`
      and instead replace it with a simple `alias_method :since, :+`.
      
      The rationale is that the only case where they differ is a case that is
      explicitly discouraged as "wrong".
      
      In my opinion, having two methods named `since` and `+` and having to figure
      out exactly what the difference is makes the codebase more confusing.
      
      However, I understand this PR is "subjective", so if you feel like it's better
      to ignore this, feel free to close the PR.
      
      Thanks!
      05affb2c
  14. 15 12月, 2014 1 次提交
    • C
      Add test for `:skip_after_callbacks_if_terminated` · 8c1889c9
      claudiob 提交于
      `define_callbacks` from `ActiveSupport::Callbacks` accepts the
      `:skip_after_callbacks_if_terminated` option since #4866 but the option
      is not tested anywhere.
      
      This commit adds tests and fixes documentation for the option, making it clear
      that halting a callback chain only stops following `before_` and `around_`
      callbacks by default.
      8c1889c9
  15. 12 12月, 2014 1 次提交
  16. 10 12月, 2014 2 次提交
  17. 05 12月, 2014 4 次提交
  18. 04 12月, 2014 1 次提交
  19. 02 12月, 2014 2 次提交
    • R
      ee73d9ff
    • R
      Prefer object/nil over `true`/`false` · bc8cc56a
      Rafael Mendonça França 提交于
      This is the project guideline and the reasons are:
      
      * That follows standard Ruby semantics.
      * Allows the implementation to avoid artificial code like !! or something ? true : false
      * You do not need to rely on the exact type of 3rd party code. For
      example, if your method returns str.end_with?('foo') you do not need to
      make sure end_with? returns a singleton. Your predicate just propagates
      predicate semantics up regardless of what end_with? returns.
      bc8cc56a