Sha256: 58458aae4659b19288aba5b57183eb7ec85707809b5b82c3c67eb85a99fa3710

Contents?: true

Size: 737 Bytes

Versions: 16

Compression:

Stored size: 737 Bytes

Contents

module ActiveRecord

  class Relation
    attr_accessor :origin, :origin_attribute
  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

16 entries across 16 versions & 1 rubygems

Version Path
hobo-1.3.0.RC lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre31 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre29 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre28 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre27 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre26 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre25 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre24 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre23 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre22 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre21 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre20 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre19 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre18 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre16 lib/hobo/extensions/active_record/relation_with_origin.rb
hobo-1.3.0.pre15 lib/hobo/extensions/active_record/relation_with_origin.rb