Sha256: c117dad4233e74fc2a015341604508d94392bd013e87014f5ed354e3cd164f10

Contents?: true

Size: 900 Bytes

Versions: 1

Compression:

Stored size: 900 Bytes

Contents

module Octopus::SingularAssociation
  def self.included(base)
    base.instance_eval do
      alias_method_chain :reader, :octopus
      alias_method_chain :writer, :octopus
      alias_method_chain :create, :octopus
      alias_method_chain :create!, :octopus
      alias_method_chain :build, :octopus
    end
  end

  def reader_with_octopus(*args)
    owner.run_on_shard { reader_without_octopus(*args) }
  end

  def writer_with_octopus(*args)
    owner.run_on_shard { writer_without_octopus(*args) }
  end

  def create_with_octopus(*args)
    owner.run_on_shard { create_without_octopus(*args) }
  end

  def create_with_octopus!(*args)
    owner.run_on_shard { create_without_octopus!(*args) }
  end

  def build_with_octopus(*args)
    owner.run_on_shard { build_without_octopus(*args) }
  end

end

ActiveRecord::Associations::SingularAssociation.send(:include, Octopus::SingularAssociation)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ar-octopus-0.8.1 lib/octopus/rails3/singular_association.rb