Sha256: 45ab6ebcc5647d0252fccf5e0f26def12747d5231945c3c4684f91410b2e6767
Contents?: true
Size: 1.54 KB
Versions: 9
Compression:
Stored size: 1.54 KB
Contents
require "flipper" require "flipper/middleware/setup_env" require "flipper/middleware/memoizer" require "flipper/cloud/configuration" require "flipper/cloud/dsl" require "flipper/cloud/middleware" module Flipper module Cloud # Public: Returns a new Flipper instance with an http adapter correctly # configured for flipper cloud. # # token - The String token for the environment from the website. # options - The Hash of options. See Flipper::Cloud::Configuration. # block - The block that configuration will be yielded to allowing you to # customize this cloud instance and its adapter. def self.new(token = nil, options = {}) options = options.merge(token: token) if token configuration = Configuration.new(options) yield configuration if block_given? DSL.new(configuration) end def self.app(flipper = nil, options = {}) env_key = options.fetch(:env_key, 'flipper') memoizer_options = options.fetch(:memoizer_options, {}) app = ->(_) { [404, { 'Content-Type'.freeze => 'application/json'.freeze }, ['{}'.freeze]] } builder = Rack::Builder.new yield builder if block_given? builder.use Flipper::Middleware::SetupEnv, flipper, env_key: env_key builder.use Flipper::Middleware::Memoizer, memoizer_options.merge(env_key: env_key) builder.use Flipper::Cloud::Middleware, env_key: env_key builder.run app klass = self builder.define_singleton_method(:inspect) { klass.inspect } # pretty rake routes output builder end end end
Version data entries
9 entries across 9 versions & 1 rubygems