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
Parker Selbert c046e60965 Return a hash rather than array from fetch_multi
The current implementation of `fetch_multi` returns an array and has no
means to easily backtrack which names yielded which results. By changing
the return value to a Hash we retain the name information. Hash#values
can be used on the response if only the values are needed.
2014-02-26 20:31:46 -06:00

1,014 B

  • Change the signature of fetch_multi to return a hash rather than an array. This makes it consistent with the output of read_multi.

    Parker Selbert

  • Introduce Concern#class_methods as a sleek alternative to clunky module ClassMethods. Add Kernel#concern to define at the toplevel without chunky module Foo; extend ActiveSupport::Concern boilerplate.

    # app/models/concerns/authentication.rb
    concern :Authentication do
      included do
        after_create :generate_private_key
      end
    
      class_methods do
        def authenticate(credentials)
          # ...
        end
      end
    
      def generate_private_key
        # ...
      end
    end
    
    # app/models/user.rb
    class User < ActiveRecord::Base
      include Authentication
    end
    

    Jeremy Kemper

Please check 4-1-stable for previous changes.