Sha256: 9846b63c36993fb0c765e43985665e5a9f15ab10b191e401b9fc363f24a44f00

Contents?: true

Size: 873 Bytes

Versions: 4

Compression:

Stored size: 873 Bytes

Contents

class ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation
  
  alias_method :association_join_without_labor, :association_join unless self.method_defined? :association_join_without_labor

  def association_join 
    association_hacks = (reflection.active_record.respond_to? :association_hacks ) ? reflection.active_record.association_hacks : nil
    
    if association_hacks and association_hacks.has_key?(reflection.name) and association_hacks[reflection.name].respond_to?(:call)
      association_hacks[reflection.name].call(self)
    else
      association_join_without_labor
    end
  end

end

class ActiveRecord::Base
  class << self
    attr_reader :association_hacks

    def hack_an_association_join(name, &generate_association)
      @association_hacks ||= {}
      
      @association_hacks[ name ] = generate_association
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
brisk-bills-0.8.2 vendor/plugins/association_hacks/lib/association_hacks.rb
brisk-bills-0.8.1 vendor/plugins/association_hacks/lib/association_hacks.rb
brisk-bills-0.7.0 vendor/plugins/association_hacks/lib/association_hacks.rb
brisk-bills-0.6.0 vendor/plugins/association_hacks/lib/association_hacks.rb