Sha256: 1939cce0819b2cc67af265fb55aa0da8392558b35684db21eb1ece9f00132f34
Contents?: true
Size: 1012 Bytes
Versions: 5
Compression:
Stored size: 1012 Bytes
Contents
# frozen_string_literal: true module DatabaseFlusher class Cleaner attr_reader :strategy def initialize(orm) @orm = orm reset_strategy end def strategy=(name) strategy_changed = name != @strategy_name stop if strategy_changed if name create_strategy(name) if strategy_changed else reset_strategy end end def clean_with(name) self.strategy = name strategy.clean_all end def start strategy.start end def stop strategy.stop end def clean strategy.clean end private def create_strategy(name) @strategy_name = name @strategy = DatabaseFlusher. const_get(classify(@orm)). const_get("#{classify(name)}Strategy").new end def reset_strategy @strategy_name = nil @strategy = DatabaseFlusher::NullStrategy.new end def classify(name) name.to_s.split('_').collect(&:capitalize).join end end end
Version data entries
5 entries across 5 versions & 1 rubygems