Sha256: d9c56204ba4c8aa1bf52c17fe469012b591ae57a65cbc770d2672605f450a71a

Contents?: true

Size: 625 Bytes

Versions: 4

Compression:

Stored size: 625 Bytes

Contents

module Mobility
  module Sequel
=begin

Backend resetter for Sequel models. Triggers backend reset when +refresh+
method is called.

=end
    class BackendResetter < Mobility::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

        model_class.class_eval do
          mod = Module.new do
            define_method :refresh do
              super().tap { instance_eval &model_reset_method }
            end
          end
          include mod
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mobility-0.1.3 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.2 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.1 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.0 lib/mobility/sequel/backend_resetter.rb