Class: AbstractFeatureBranch::Configuration

Inherits:
Object
  • Object
show all
Includes:
Memoizable
Defined in:
lib/abstract_feature_branch/configuration.rb

Constant Summary collapse

MUTEX =
{
  '@application_root': Mutex.new,
  '@application_environment': Mutex.new,
  '@logger': Mutex.new,
  '@cacheable': Mutex.new,
  '@feature_store_live_fetching': Mutex.new,
}

Instance Method Summary collapse

Instance Method Details

#application_environmentObject



25
26
27
# File 'lib/abstract_feature_branch/configuration.rb', line 25

def application_environment
  memoize_thread_safe(:@application_environment, :initialize_application_environment)
end

#application_environment=(environment) ⇒ Object



28
29
30
# File 'lib/abstract_feature_branch/configuration.rb', line 28

def application_environment=(environment)
  @application_environment = environment
end

#application_rootObject



16
17
18
# File 'lib/abstract_feature_branch/configuration.rb', line 16

def application_root
  memoize_thread_safe(:@application_root, :initialize_application_root)
end

#application_root=(path) ⇒ Object



19
20
21
# File 'lib/abstract_feature_branch/configuration.rb', line 19

def application_root=(path)
  @application_root = path
end

#cacheableObject



43
44
45
# File 'lib/abstract_feature_branch/configuration.rb', line 43

def cacheable
  memoize_thread_safe(:@cacheable, :initialize_cacheable)
end

#cacheable=(cacheable) ⇒ Object



46
47
48
# File 'lib/abstract_feature_branch/configuration.rb', line 46

def cacheable=(cacheable)
  @cacheable = cacheable
end

#feature_storeObject Also known as: user_features_storage



58
59
60
# File 'lib/abstract_feature_branch/configuration.rb', line 58

def feature_store
  @feature_store
end

#feature_store=(feature_store) ⇒ Object Also known as: user_features_storage=



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/abstract_feature_branch/configuration.rb', line 63

def feature_store=(feature_store)
  if feature_store.nil?
    @feature_store = nil
  else
    begin
      @feature_store = feature_store.is_a?(::ConnectionPool) ? AbstractFeatureBranch::Redis::ConnectionPoolToRedisAdapter.new(feature_store) : feature_store
    rescue NameError => e
      logger.debug { "connection_pool gem is not available" }
      @feature_store = feature_store
    end
  end
end

#feature_store_live_fetchingObject Also known as: feature_store_live_fetching?



77
78
79
# File 'lib/abstract_feature_branch/configuration.rb', line 77

def feature_store_live_fetching
  memoize_thread_safe(:@feature_store_live_fetching, :initialize_feature_store_live_fetching)
end

#feature_store_live_fetching=(value) ⇒ Object



82
83
84
# File 'lib/abstract_feature_branch/configuration.rb', line 82

def feature_store_live_fetching=(value)
  @feature_store_live_fetching = value
end

#initialize_application_environmentObject



31
32
33
# File 'lib/abstract_feature_branch/configuration.rb', line 31

def initialize_application_environment
  self.application_environment = defined?(Rails) ? Rails.env.to_s : ENV['APP_ENV'] || 'development'
end

#initialize_application_rootObject



22
23
24
# File 'lib/abstract_feature_branch/configuration.rb', line 22

def initialize_application_root
  self.application_root = defined?(Rails) ? Rails.root : '.'
end

#initialize_cacheableObject



49
50
51
52
53
54
55
56
# File 'lib/abstract_feature_branch/configuration.rb', line 49

def initialize_cacheable
  self.cacheable = {
    :development => false,
    :test => true,
    :staging => true,
    :production => true
  }
end

#initialize_feature_store_live_fetchingObject



86
87
88
# File 'lib/abstract_feature_branch/configuration.rb', line 86

def initialize_feature_store_live_fetching
  @feature_store_live_fetching = false
end

#initialize_loggerObject



40
41
42
# File 'lib/abstract_feature_branch/configuration.rb', line 40

def initialize_logger
  self.logger = defined?(Rails) && Rails.logger ? Rails.logger : Logger.new(STDOUT)
end

#loggerObject



34
35
36
# File 'lib/abstract_feature_branch/configuration.rb', line 34

def logger
  memoize_thread_safe(:@logger, :initialize_logger)
end

#logger=(logger) ⇒ Object



37
38
39
# File 'lib/abstract_feature_branch/configuration.rb', line 37

def logger=(logger)
  @logger = logger
end