Module: TimePilot::Features

Defined in:
lib/time_pilot/time_pilot.rb

Overview

Including this module makes a class a TimePilot class

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



52
53
54
# File 'lib/time_pilot/time_pilot.rb', line 52

def self.included(base)
  base.send :extend, ClassMethods
end

Instance Method Details

#pilot_disable_feature(feature_name) ⇒ Object



75
76
77
78
# File 'lib/time_pilot/time_pilot.rb', line 75

def pilot_disable_feature(feature_name)
  key_name = "#{feature_name}:#{self.class.to_s.underscore}_ids"
  TimePilot.redis.srem TimePilot.key(key_name), id
end

#pilot_enable_feature(feature_name) ⇒ Object



70
71
72
73
# File 'lib/time_pilot/time_pilot.rb', line 70

def pilot_enable_feature(feature_name)
  key_name = "#{feature_name}:#{self.class.to_s.underscore}_ids"
  TimePilot.redis.sadd TimePilot.key(key_name), id
end

#pilot_feature_enabled?(feature_name) ⇒ Boolean

Returns:

  • (Boolean)


80
81
82
83
84
85
86
87
# File 'lib/time_pilot/time_pilot.rb', line 80

def pilot_feature_enabled?(feature_name)
  TimePilot.redis.pipelined do
    self.class.time_pilot_groups.each do |group|
      method = group.to_s == self.class.to_s.underscore ? 'id' : group + '_id'
      TimePilot.redis.sismember TimePilot.key("#{feature_name}:#{group}_ids"), send(method)
    end
  end.include? true
end