Sha256: f8820703d3f094d5b1fd76ec8feaac73aa0cb1eda82832fe4b52a41a6c4c61b4
Contents?: true
Size: 1.06 KB
Versions: 3
Compression:
Stored size: 1.06 KB
Contents
module ActiveRecord class Relation attr_accessor :origin, :origin_attribute def member_class @klass end end module SpawnMethods def merge_with_origin(r) merged = merge_without_origin(r) merged.origin ||= r.respond_to?(:origin) && r.origin merged.origin_attribute ||= r.respond_to?(:origin_attribute) && r.origin_attribute merged end alias_method_chain :merge, :origin end module Associations class AssociationCollection def scoped_with_origin relation = scoped_without_origin.clone relation.origin = @owner relation.origin_attribute = @reflection.name relation end alias_method_chain :scoped, :origin def method_missing_with_origin(method, *args, &block) res = method_missing_without_origin(method, *args, &block) res.origin = @owner if res.respond_to?(:origin) res.origin_attribute = @reflection.name if res.respond_to?(:origin_attribute) res end alias_method_chain :method_missing, :origin end end end
Version data entries
3 entries across 3 versions & 1 rubygems