Class: Mobility::Sequel::BackendResetter

Inherits:
BackendResetter show all
Defined in:
lib/mobility/sequel/backend_resetter.rb

Overview

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

Instance Method Summary collapse

Methods inherited from BackendResetter

for

Constructor Details

#initialize(attribute_names) { ... } ⇒ BackendResetter

Returns a new instance of BackendResetter.

Parameters:

  • attribute_names (Array<String>)

    Names of attributes whose backends should be reset

Yields:

  • Backend to reset as context for block

Raises:

  • (ArgumentError)

    if no block is provided.


12
13
14
15
16
17
18
19
20
# File 'lib/mobility/sequel/backend_resetter.rb', line 12

def initialize(attribute_names, &block)
  super

  model_reset_method = @model_reset_method

  define_method :refresh do
    super().tap { instance_eval(&model_reset_method) }
  end
end