Sha256: e077e63e10ba5cfe286ba287e054c1c7047f5d96ab4f1b495db846a6829e39d0
Contents?: true
Size: 1.75 KB
Versions: 3
Compression:
Stored size: 1.75 KB
Contents
# frozen_string_literal: true # A monkey-patch for Active Record that enables association auto-decoration. module ActiveDecorator module Monkey module ActiveRecord module Associations module Association def target ActiveDecorator::Decorator.instance.decorate_association(owner, super) end end # @see https://github.com/rails/rails/commit/03855e790de2224519f55382e3c32118be31eeff if Rails.version.to_f < 4.1 module CollectionAssociation private def first_or_last(*) ActiveDecorator::Decorator.instance.decorate_association(owner, super) end end elsif Rails.version.to_f < 5.1 module CollectionAssociation private def first_nth_or_last(*) ActiveDecorator::Decorator.instance.decorate_association(owner, super) end end end if Rails.version.to_f >= 4.0 module CollectionProxy def take(limit = nil) ActiveDecorator::Decorator.instance.decorate_association(@association.owner, super) end if Rails.version.to_f >= 5.1 def last(limit = nil) ActiveDecorator::Decorator.instance.decorate_association(@association.owner, super) end private def find_nth_with_limit(index, limit) ActiveDecorator::Decorator.instance.decorate_association(@association.owner, super) end def find_nth_from_last(index) ActiveDecorator::Decorator.instance.decorate_association(@association.owner, super) end end end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems