Promote time zone aware attributes to a first class type decorator

This refactoring revealed the need for another form of decoration, which
takes a proc to select which it applies to (There's a *lot* of cases
where this form can be used). To avoid duplication, we can re-implement
the old decoration in terms of the proc-based decoration.

The reason we're `instance_exec`ing the matcher is for cases such as
time zone aware attributes, where a decorator is defined in a parent
class, and a method called in the matcher is overridden by a child
class. The matcher will close over the parent, and evaluate in its
context, which is not the behavior we want.
Yes
On Jun 16, 2014 3:41 PM, "Eugene Gilburg" <notifications@github.com> wrote:

> In activerecord/lib/active_record/attribute_decorators.rb:
>
> >          decorations.inject(type) do |new_type, block|
> >            block.call(new_type)
> >          end
> >        end
> > +
> > +      private
> > +
> > +      def decorators_for(context, name, type)
> > +        matching(context, name, type).map(&:last)
> > +      end
> > +
> > +      def matching(context, name, type)
> > +        @decorations.values.select do |(matcher, _)|
>
> are parentheses needed here?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/rails/rails/pull/15760/files#r13832433>.
>