Sha256: 7acab4463fe5abedfc2c797666cfc062058013b7587354954e4c3540082ce897

Contents?: true

Size: 624 Bytes

Versions: 21

Compression:

Stored size: 624 Bytes

Contents

# frozen_string_literal: true
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

      # (see Mobility::BackendResetter#initialize)
      def initialize(attribute_names, &block)
        super

        model_reset_method = @model_reset_method

        define_method :reload do |*args|
          super(*args).tap { instance_eval(&model_reset_method) }
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
mobility-0.8.13 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.11 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.10 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.9 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.8 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.7 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.6 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.5 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.4 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.3 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.2 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.1 lib/mobility/active_record/backend_resetter.rb
mobility-0.8.0 lib/mobility/active_record/backend_resetter.rb
mobility-0.7.6 lib/mobility/active_record/backend_resetter.rb
mobility-0.7.5 lib/mobility/active_record/backend_resetter.rb
mobility-0.7.4 lib/mobility/active_record/backend_resetter.rb
mobility-0.7.3 lib/mobility/active_record/backend_resetter.rb
mobility-0.7.2 lib/mobility/active_record/backend_resetter.rb
mobility-0.7.1 lib/mobility/active_record/backend_resetter.rb
mobility-0.7.0 lib/mobility/active_record/backend_resetter.rb