Sha256: d5e991c76d262fb57532c5d8866458429556fb8c978b9d163f1f70a5f1b5bfdd

Contents?: true

Size: 684 Bytes

Versions: 15

Compression:

Stored size: 684 Bytes

Contents

require "mobility/active_model/backend_resetter"

module Mobility
  module ActiveRecord
=begin

Backend resetter for ActiveRecord models. Adds hook on +reload+ event to
{Mobility::ActiveModel::BackendResetter}.

=end
    class BackendResetter < Mobility::ActiveModel::BackendResetter

      # @param [Class] model_class Class of model to which backend resetter will be applied
      def included(model_class)
        model_reset_method = @model_reset_method

        mod = Module.new do
          define_method :reload do |*args|
            super(*args).tap { instance_eval(&model_reset_method) }
          end
        end
        model_class.include mod
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mobility-0.4.3 lib/mobility/active_record/backend_resetter.rb
mobility-0.4.2 lib/mobility/active_record/backend_resetter.rb
mobility-0.4.1 lib/mobility/active_record/backend_resetter.rb
mobility-0.4.0 lib/mobility/active_record/backend_resetter.rb
mobility-0.3.6 lib/mobility/active_record/backend_resetter.rb
mobility-0.3.5 lib/mobility/active_record/backend_resetter.rb
mobility-0.3.4 lib/mobility/active_record/backend_resetter.rb
mobility-0.3.3 lib/mobility/active_record/backend_resetter.rb
mobility-0.3.2 lib/mobility/active_record/backend_resetter.rb
mobility-0.3.1 lib/mobility/active_record/backend_resetter.rb
mobility-0.3.0 lib/mobility/active_record/backend_resetter.rb
mobility-0.2.3 lib/mobility/active_record/backend_resetter.rb
mobility-0.2.2 lib/mobility/active_record/backend_resetter.rb
mobility-0.2.1 lib/mobility/active_record/backend_resetter.rb
mobility-0.2.0 lib/mobility/active_record/backend_resetter.rb