module Flipper::UI

Constants

Error

All flipper ui errors inherit from this.

RequestMethodNotSupported

Raised when a request method (get, post, etc.) is called for an action that does not know how to handle it.

Public Class Methods

app(flipper = nil, options = {}) { |builder| ... } click to toggle source
# File lib/flipper/ui.rb, line 21
def self.app(flipper = nil, options = {})
  env_key = options.fetch(:env_key, 'flipper')
  rack_protection_options = options.fetch(:rack_protection, use: :authenticity_token)

  app = ->(_) { [200, { Rack::CONTENT_TYPE => 'text/html' }, ['']] }
  builder = Rack::Builder.new
  yield builder if block_given?
  builder.use Rack::Protection, rack_protection_options
  builder.use Rack::MethodOverride
  builder.use Flipper::Middleware::SetupEnv, flipper, env_key: env_key
  builder.use Flipper::UI::Middleware, flipper: flipper, env_key: env_key
  builder.run app
  klass = self
  app = builder.to_app
  app.define_singleton_method(:inspect) { klass.inspect } # pretty rake routes output
  app
end
configuration() click to toggle source
# File lib/flipper/ui.rb, line 44
def self.configuration
  @configuration ||= ::Flipper::UI::Configuration.new
end
configure() { |configuration| ... } click to toggle source

Public: yields configuration instance for customizing UI text

# File lib/flipper/ui.rb, line 40
def self.configure
  yield(configuration)
end
root() click to toggle source
# File lib/flipper/ui.rb, line 17
def self.root
  @root ||= Pathname(__FILE__).dirname.expand_path.join('ui')
end