Sha256: 8629f52c163670ecc62010b89de82178206112a4c6254bb727e4ca1dd63fe878

Contents?: true

Size: 1.01 KB

Versions: 17

Compression:

Stored size: 1.01 KB

Contents

module Octopus
  module Rails2
    module Persistence
      def self.included(base)
        base.instance_eval do 
          alias_method_chain :destroy, :octopus
          alias_method_chain :delete, :octopus
          alias_method_chain :reload, :octopus
        end
      end

      def delete_with_octopus()
        if should_set_current_shard?
          Octopus.using(self.current_shard) { delete_without_octopus() }
        else
          delete_without_octopus()
        end
      end

      def destroy_with_octopus()
        if should_set_current_shard?
          Octopus.using(self.current_shard) { destroy_without_octopus() }
        else
          destroy_without_octopus()
        end
      end

      def reload_with_octopus(options = nil)
        if should_set_current_shard?
          Octopus.using(self.current_shard) { reload_without_octopus(options) }
        else
          reload_without_octopus(options)
        end
      end
    end
  end
end

ActiveRecord::Base.send(:include, Octopus::Rails2::Persistence)

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ar-octopus-0.4.0 lib/octopus/rails2/persistence.rb
ar-octopus-0.3.4 lib/octopus/rails2/persistence.rb
ar-octopus-0.3.3 lib/octopus/rails2/persistence.rb
ar-octopus-0.3.2 lib/octopus/rails2/persistence.rb
ar-octopus-0.3.1 lib/octopus/rails2/persistence.rb
ar-octopus-0.3.0 lib/octopus/rails2/persistence.rb
ar-octopus-0.2.2 lib/octopus/rails2/persistence.rb
ar-octopus-0.2.1 lib/octopus/rails2/persistence.rb
ar-octopus-0.2.0 lib/octopus/rails2/persistence.rb
ar-octopus-0.1.2 lib/octopus/rails2/persistence.rb
ar-octopus-0.1.1 lib/octopus/rails2/persistence.rb
ar-octopus-0.1.0 lib/octopus/rails2/persistence.rb
ar-octopus-0.0.30 lib/octopus/rails2/persistence.rb
ar-octopus-0.0.29 lib/octopus/rails2/persistence.rb
ar-octopus-0.0.28 lib/octopus/rails2/persistence.rb
ar-octopus-0.0.27 lib/octopus/rails2/persistence.rb
ar-octopus-0.0.26 lib/octopus/rails2/persistence.rb