Class: TalkToYourApp::Plugins::Flipper::Plugin

Inherits:
TalkToYourApp::Plugin show all
Defined in:
lib/talk_to_your_app/plugins/flipper/plugin.rb

Class Method Summary collapse

Methods inherited from TalkToYourApp::Plugin

describe_tool, log_level, requires_gem, tools, wired_spec

Class Method Details

.validate_enablement!(options) ⇒ Object

Flipper toggles flags, so it needs a writer — connection: false is invalid, and a :reading connection fails at boot (previously a misrole'd connection booted and failed only on the first write).



141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/talk_to_your_app/plugins/flipper/plugin.rb', line 141

def self.validate_enablement!(options)
  unless options[:connection]
    raise TalkToYourApp::ConfigurationError,
      "talk_to_your_app: the Flipper plugin requires a connection declared role: :writing — " \
      "`config.plugin :flipper, connection: :your_writer`. `connection: false` is not valid."
  end

  spec = wired_spec(options) # nil for an unregistered name (ConnectionRegistry.validate! owns that)
  return unless spec&.reading?

  raise TalkToYourApp::ConfigurationError,
    "talk_to_your_app: the Flipper plugin's connection #{spec.name.inspect} must be declared with " \
    "role: :writing (got role: #{spec.role.inspect}). Flipper writes flag state."
end