Class: Blackbeard::Group

Inherits:
Storable show all
Defined in:
lib/blackbeard/group.rb

Instance Attribute Summary

Attributes inherited from Storable

#id, #new_record

Instance Method Summary collapse

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

#definitionObject



30
31
32
# File 'lib/blackbeard/group.rb', line 30

def definition
  config.group_definitions[self.id.to_sym]
end

#metric_data(metric) ⇒ Object



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

def metric_data(metric)
  GroupMetric.new(self,metric).metric_data
end

#nameObject



9
10
11
# File 'lib/blackbeard/group.rb', line 9

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

#segment_for(context) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/blackbeard/group.rb', line 13

def segment_for(context)
  return nil unless definition
  segment = definition.call(context.user, context.controller)
  segment_id = case segment
  when  false
    nil
  when nil
    nil
  when true
    self.id
  else
    segment.to_s
  end
  add_segment(segment_id) unless segment_id.nil?
  segment_id
end