Module: FeatureFlagger::Model

Defined in:
lib/feature_flagger/model.rb

Overview

Model provides convinient methods for Rails Models class Account

include FeatureFlagger::Model

end

Example: Account.first.rollout?([:email_marketing, :new_awesome_feature]) #=> true

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


11
12
13
# File 'lib/feature_flagger/model.rb', line 11

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#release!(feature_key) ⇒ Object


21
22
23
24
25
# File 'lib/feature_flagger/model.rb', line 21

def release!(feature_key)
  resource_name = self.class.rollout_resource_name
  Feature.new(feature_key, resource_name).fetch!
  FeatureFlagger.control.release!(feature_key, id, resource_name)
end

#rollout?(feature_key) ⇒ Boolean

Returns:

  • (Boolean)

15
16
17
18
19
# File 'lib/feature_flagger/model.rb', line 15

def rollout?(feature_key)
  resource_name = self.class.rollout_resource_name
  Feature.new(feature_key, resource_name).fetch!
  FeatureFlagger.control.rollout?(feature_key, id, resource_name)
end

#unrelease!(feature_key) ⇒ Object


27
28
29
30
31
# File 'lib/feature_flagger/model.rb', line 27

def unrelease!(feature_key)
  resource_name = self.class.rollout_resource_name
  Feature.new(feature_key, resource_name).fetch!
  FeatureFlagger.control.unrelease!(feature_key, id, resource_name)
end