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.



9
10
11
12
# File 'lib/rollout_ui/feature.rb', line 9

def initialize(name)
  @wrapper = Wrapper.new
  @name = name
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



18
19
20
# File 'lib/rollout_ui/feature.rb', line 18

def groups
  redis.smembers(group_key(name))
end

#groups=(groups) ⇒ Object



30
31
32
33
# File 'lib/rollout_ui/feature.rb', line 30

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

#percentageObject



14
15
16
# File 'lib/rollout_ui/feature.rb', line 14

def percentage
  redis.get(percentage_key(name))
end

#percentage=(percentage) ⇒ Object



26
27
28
# File 'lib/rollout_ui/feature.rb', line 26

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

#user_idsObject



22
23
24
# File 'lib/rollout_ui/feature.rb', line 22

def user_ids
  redis.smembers(user_key(name))
end

#user_ids=(ids) ⇒ Object



35
36
37
38
# File 'lib/rollout_ui/feature.rb', line 35

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