Module: Dolphin::Helper

Defined in:
lib/dolphin/helper.rb

Overview

Given a feature name, this uses the global Dolphin::FeatureStore to go to a flipper (a block), which it then evaluates to determine if it is available

Instance Method Summary collapse

Instance Method Details

#feature(name, partial_options = {}) ⇒ Object


8
9
10
11
12
13
14
15
16
# File 'lib/dolphin/helper.rb', line 8

def feature(name, partial_options = {})
  return nil unless feature?(name)

  if partial_options[:partial] && respond_to?(:render)
    render partial_options
  elsif block_given?
    yield
  end
end

#feature?(name) ⇒ Boolean

Returns:

  • (Boolean)

18
19
20
# File 'lib/dolphin/helper.rb', line 18

def feature?(name)
  Dolphin.feature_available?(name)
end