Class: RolloutUi::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/rollout_ui/feature.rb

Defined Under Namespace

Classes: User

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Feature

Returns a new instance of Feature.



7
8
9
10
# File 'lib/rollout_ui/feature.rb', line 7

def initialize(name)
  @wrapper = Wrapper.new
  @name = name.to_sym
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/rollout_ui/feature.rb', line 5

def name
  @name
end

Instance Method Details

#groupsObject



16
17
18
# File 'lib/rollout_ui/feature.rb', line 16

def groups
  rollout.get(feature_for(name)).groups
end

#groups=(groups) ⇒ Object



28
29
30
31
# File 'lib/rollout_ui/feature.rb', line 28

def groups=(groups)
  self.groups.each { |group| rollout.deactivate_group(name, group) }
  groups.each { |group| rollout.activate_group(name, group) unless group.to_s.empty? }
end

#percentageObject



12
13
14
# File 'lib/rollout_ui/feature.rb', line 12

def percentage
  rollout.get(feature_for(name)).percentage.to_s
end

#percentage=(percentage_val) ⇒ Object



24
25
26
# File 'lib/rollout_ui/feature.rb', line 24

def percentage=(percentage_val)
  rollout.activate_percentage(name, percentage_val.to_i)
end

#user_idsObject



20
21
22
# File 'lib/rollout_ui/feature.rb', line 20

def user_ids
  rollout.get(feature_for(name)).users
end

#user_ids=(ids) ⇒ Object



33
34
35
36
# File 'lib/rollout_ui/feature.rb', line 33

def user_ids=(ids)
  self.user_ids.each { |id| rollout.deactivate_user(name, User.new(id)) unless id.to_s.empty? }
  ids.each { |id| rollout.activate_user(name, User.new(id)) unless id.to_s.empty? }
end