Class: Blackbeard::Feature

Inherits:
Storable show all
Includes:
FeatureRollout
Defined in:
lib/blackbeard/feature.rb

Instance Attribute Summary

Attributes inherited from Storable

#id, #new_record

Instance Method Summary collapse

Methods included from FeatureRollout

#active_segment?, #active_user?, #active_visitor?, #id_to_int, #rollout?

Methods inherited from Storable

#==, all, all_keys, count, create, find, find_or_create, #initialize, #key, key_for, #master_key, master_key, new_from_key, new_from_keys, #new_record?, on_reload, on_reload_methods, on_save, on_save_methods, #reload, #save, set_master_key

Methods included from StorableAttributes

included

Methods included from StorableHasSet

included

Methods included from StorableHasMany

included

Methods included from ConfigurationMethods

#config, #db, #guest_method, included, #tz

Constructor Details

This class inherits a constructor from Blackbeard::Storable

Instance Method Details

#active_for?(context) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
32
# File 'lib/blackbeard/feature.rb', line 23

def active_for?(context)
  case status
  when 'active'
    true
  when 'rollout'
    rollout?(context)
  else
    false
  end
end

#nameObject



38
39
40
# File 'lib/blackbeard/feature.rb', line 38

def name
  storable_attributes_hash['name'] || id
end

#segments_for(group_id) ⇒ Object



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

def segments_for(group_id)
  (group_segments && group_segments[group_id.to_s]) || []
end

#set_segments_for(group_id, *segments) ⇒ Object



16
17
18
19
20
21
# File 'lib/blackbeard/feature.rb', line 16

def set_segments_for(group_id, *segments)
  segments = Array(segments).flatten.compact.map{|a| a.to_s}
  grp_segments = self.group_segments || {}
  grp_segments[group_id.to_s] = segments
  self.group_segments = grp_segments
end

#statusObject



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

def status
  storable_attributes_hash['status'] || "inactive"
end