lib/slavery.rb in slavery-1.4.2 vs lib/slavery.rb in slavery-1.4.3

- old
+ new

@@ -1,9 +1,8 @@ require 'slavery/version' require 'slavery/railtie' require 'active_record' -require 'active_support/core_ext/module/attribute_accessors' module Slavery extend ActiveSupport::Concern included do @@ -14,18 +13,19 @@ end end class Error < StandardError; end - mattr_accessor :disabled, :env, :spec_key - class << self + attr_accessor :disabled + attr_writer :env, :spec_key + def spec_key - case @@spec_key - when String then @@spec_key - when Proc then @@spec_key = @@spec_key.call - when NilClass then @@spec_key = "#{Slavery.env}_slave" + case @spec_key + when String then @spec_key + when Proc then @spec_key = @spec_key.call + when NilClass then @spec_key = "#{Slavery.env}_slave" end end def on_slave(&block) run true, &block @@ -42,10 +42,10 @@ ensure Thread.current[:on_slave] = old_value end def env - @@env ||= defined?(Rails) ? Rails.env.to_s : 'development' + @env ||= defined?(Rails) ? Rails.env.to_s : 'development' end end module ClassMethods def on_slave