Module: Prefab

Defined in:
lib/prefab/criteria_evaluator.rb,
lib/prefab/error.rb,
lib/prefab/client.rb,
lib/prefab/prefab.rb,
lib/prefab/context.rb,
lib/prefab/options.rb,
lib/prefab-cloud-ruby.rb,
lib/prefab/encryption.rb,
lib/prefab/evaluation.rb,
lib/prefab/sse_logger.rb,
lib/prefab/time_helpers.rb,
lib/prefab/config_client.rb,
lib/prefab/config_loader.rb,
lib/prefab/context_shape.rb,
lib/prefab/logger_client.rb,
lib/prefab/periodic_sync.rb,
lib/prefab/static_logger.rb,
lib/prefab/config_resolver.rb,
lib/prefab/http_connection.rb,
lib/prefab/internal_logger.rb,
lib/prefab/rate_limit_cache.rb,
lib/prefab/yaml_config_parser.rb,
lib/prefab/exponential_backoff.rb,
lib/prefab/feature_flag_client.rb,
lib/prefab/local_config_parser.rb,
lib/prefab/log_path_aggregator.rb,
lib/prefab/config_value_wrapper.rb,
lib/prefab/config_value_unwrapper.rb,
lib/prefab/logging/formatter_base.rb,
lib/prefab/config_client_presenter.rb,
lib/prefab/weighted_value_resolver.rb,
lib/prefab/context_shape_aggregator.rb,
lib/prefab/resolved_config_presenter.rb,
lib/prefab/errors/env_var_parse_error.rb,
lib/prefab/errors/uninitialized_error.rb,
lib/prefab/example_contexts_aggregator.rb,
lib/prefab/errors/invalid_api_key_error.rb,
lib/prefab/errors/missing_default_error.rb,
lib/prefab/evaluation_summary_aggregator.rb,
lib/prefab/errors/initialization_timeout_error.rb,
lib/prefab/log_subscribers/action_controller_subscriber.rb

Overview

Modified from github.com/reidmorrison/rails_semantic_logger/blob/master/lib/rails_semantic_logger/action_controller/log_subscriber.rb

Copyright 2012, 2013, 2014, 2015 Reid Morrison

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License.

You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Defined Under Namespace

Modules: Errors, LogSubscribers, Logging, PeriodicSync, TimeHelpers Classes: BootstrappingConfigClient, Client, ConfigClient, ConfigClientPresenter, ConfigLoader, ConfigResolver, ConfigValueUnwrapper, ConfigValueWrapper, Context, ContextShape, ContextShapeAggregator, CriteriaEvaluator, Encryption, Error, Evaluation, EvaluationSummaryAggregator, ExampleContextsAggregator, ExponentialBackoff, FeatureFlagClient, HttpConnection, InternalLogger, LocalConfigParser, LogPathAggregator, LoggerClient, Options, RateLimitCache, ResolvedConfigPresenter, SseLogger, StaticLogger, WeightedValueResolver, YAMLConfigParser

Constant Summary collapse

NO_DEFAULT_PROVIDED =
:no_default_provided
VERSION =
File.read(File.dirname(__FILE__) + '/../VERSION').strip
@@lock =
Concurrent::ReadWriteLock.new

Class Method Summary collapse

Class Method Details

.enabled?(feature_name, jit_context = NO_DEFAULT_PROVIDED) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
37
# File 'lib/prefab/prefab.rb', line 34

def self.enabled?(feature_name, jit_context = NO_DEFAULT_PROVIDED)
  ensure_initialized feature_name
  @singleton.enabled?(feature_name, jit_context)
end

.forkObject



17
18
19
20
21
22
# File 'lib/prefab/prefab.rb', line 17

def self.fork
  ensure_initialized
  @@lock.with_write_lock {
    @singleton = @singleton.fork
  }
end

.get(key, properties = NO_DEFAULT_PROVIDED) ⇒ Object



29
30
31
32
# File 'lib/prefab/prefab.rb', line 29

def self.get(key, properties = NO_DEFAULT_PROVIDED)
  ensure_initialized key
  @singleton.get(key, properties)
end

.init(options = Prefab::Options.new) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/prefab/prefab.rb', line 6

def self.init(options = Prefab::Options.new)
  unless @singleton.nil?
    Prefab::LoggerClient.instance.warn 'Prefab already initialized.'
    return @singleton
  end

  @@lock.with_write_lock {
    @singleton = Prefab::Client.new(options)
  }
end

.instanceObject



44
45
46
47
# File 'lib/prefab/prefab.rb', line 44

def self.instance
  ensure_initialized
  @singleton
end

.set_rails_loggersObject



24
25
26
27
# File 'lib/prefab/prefab.rb', line 24

def self.set_rails_loggers
  ensure_initialized
  @singleton.set_rails_loggers
end

.with_context(properties, &block) ⇒ Object



39
40
41
42
# File 'lib/prefab/prefab.rb', line 39

def self.with_context(properties, &block)
  ensure_initialized
  @singleton.with_context(properties, &block)
end