Sha256: 994de503d81a079b17b1d6867fd8b8f0ae00039e40290b4da64ba46e1bdadb0d

Contents?: true

Size: 626 Bytes

Versions: 15

Compression:

Stored size: 626 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

15 entries across 15 versions & 1 rubygems

Version Path
mobility-0.1.20 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.19 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.18 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.17 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.16 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.15 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.14 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.13 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.12 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.11 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.10 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.7 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.6 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.5 lib/mobility/sequel/backend_resetter.rb
mobility-0.1.4 lib/mobility/sequel/backend_resetter.rb