Sha256: b6d5139a6f43632a7defb74b700d1c3e95cc02b3889369007803e6e07c08c75b
Contents?: true
Size: 945 Bytes
Versions: 1
Compression:
Stored size: 945 Bytes
Contents
module Octopus::AssociationCollection METHODS = %w[ reader writer ids_reader ids_writer create create! build any? count empty? first include? last length load_target many? size select uniq ] def self.included(base) base.instance_eval do METHODS.each do |m| alias_method_chain m.to_sym, :octopus end end end METHODS.each do |m| m =~ /([^!?]+)([!?])?/ method, punctuation = [ $1, $2 ] with = :"#{method}_with_octopus#{punctuation}" without = :"#{method}_without_octopus#{punctuation}" define_method with do |*args, &block| @owner.run_on_shard { send(without, *args, &block) } end end def should_wrap_the_connection? @owner.respond_to?(:current_shard) && @owner.current_shard != nil end end ActiveRecord::Associations::CollectionAssociation.send(:include, Octopus::AssociationCollection)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ar-octopus-0.8.1 | lib/octopus/association_collection.rb |