1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/CHANGELOG.md
Sean Griffin 2c5a8ba6f6 Don't blank pad day of the month when formatting dates
We are currently using `%e` which adds a space before the result if the
digit is a single number. This leads to strings like `February  2, 2016`
which is undesireable. I've opted to replace with 0 padding instead of
removing the padding entirely, to preserve compatibility for those
relying on the fact that the width is constant, and to be consistent
with time formatting.

Fixes #25251.
2016-06-02 11:47:22 -04:00

1.6 KiB

  • Date.to_s doesn't produce too many spaces. For example, to_s(:short) will now produce 01 Feb instead of 1 Feb.

    Fixes #25251.

    Sean Griffin

  • Introduce Module#delegate_missing_to.

    When building a decorator, a common pattern emerges:

    class Partition
      def initialize(first_event)
        @events = [ first_event ]
      end
    
      def people
        if @events.first.detail.people.any?
          @events.collect { |e| Array(e.detail.people) }.flatten.uniq
        else
          @events.collect(&:creator).uniq
        end
      end
    
      private
        def respond_to_missing?(name, include_private = false)
          @events.respond_to?(name, include_private)
        end
    
        def method_missing(method, *args, &block)
          @events.send(method, *args, &block)
        end
    end
    

    With Module#delegate_missing_to, the above is condensed to:

    class Partition
      delegate_missing_to :@events
    
      def initialize(first_event)
        @events = [ first_event ]
      end
    
      def people
        if @events.first.detail.people.any?
          @events.collect { |e| Array(e.detail.people) }.flatten.uniq
        else
          @events.collect(&:creator).uniq
        end
      end
    end
    

    Genadi Samokovarov, DHH

  • Rescuable: If a handler doesn't match the exception, check for handlers matching the exception's cause.

    Jeremy Daer

Please check 5-0-stable for previous changes.