Sha256: 034f146806736bded88883f5759605b5f0af9b91a965178bc67b55c0c71a36b1

Contents?: true

Size: 711 Bytes

Versions: 5

Compression:

Stored size: 711 Bytes

Contents

module VestalVersions
  # Ties into the existing ActiveRecord::Base#reload method to ensure that version information
  # is properly reset.
  module Reload
    def self.included(base) # :nodoc:
      base.class_eval do
        include InstanceMethods

        alias_method_chain :reload, :versions
      end
    end

    # Adds instance methods into ActiveRecord::Base to tap into the +reload+ method.
    module InstanceMethods
      # Overrides ActiveRecord::Base#reload, resetting the instance-variable-cached version number
      # before performing the original +reload+ method.
      def reload_with_versions(*args)
        reset_version
        reload_without_versions(*args)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
nickjones-vestal_versions-1.0.3 lib/vestal_versions/reload.rb
bitfluent-vestal_versions-1.1.0 lib/vestal_versions/reload.rb
vestal_versions-1.0.2 lib/vestal_versions/reload.rb
vestal_versions-1.0.1 lib/vestal_versions/reload.rb
vestal_versions-1.0.0 lib/vestal_versions/reload.rb