Module: TimePilot

Defined in:
lib/time_pilot/web.rb,
lib/time_pilot/version.rb,
lib/time_pilot/time_pilot.rb,
lib/time_pilot/configuration.rb

Defined Under Namespace

Modules: Features Classes: Configuration, Web

Constant Summary collapse

VERSION =
'1.0.2'.freeze
NAMESPACE =
'timepilot'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.group_classesObject (readonly)

Returns the value of attribute group_classes.



13
14
15
# File 'lib/time_pilot/time_pilot.rb', line 13

def group_classes
  @group_classes
end

Class Method Details

.configure {|@config| ... } ⇒ Object

Yields:

  • (@config)


16
17
18
19
20
# File 'lib/time_pilot/time_pilot.rb', line 16

def self.configure
  @config ||= Configuration.new
  yield @config
  @config.features.each { |f| define_feature_methods(f) }
end

.define_feature_methods(feature_name) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/time_pilot/time_pilot.rb', line 22

def self.define_feature_methods(feature_name)
  Features.module_eval do
    unless method_defined?("enable_#{feature_name}")
      define_method "enable_#{feature_name}" do
        pilot_enable_feature(feature_name)
      end

      define_method "disable_#{feature_name}" do
        pilot_disable_feature(feature_name)
      end

      define_method "#{feature_name}_enabled?" do
        pilot_feature_enabled?(feature_name)
      end
    end
  end
end

.featuresObject



40
41
42
# File 'lib/time_pilot/time_pilot.rb', line 40

def self.features
  @config.features
end

.key(name) ⇒ Object



48
49
50
# File 'lib/time_pilot/time_pilot.rb', line 48

def self.key(name)
  "#{NAMESPACE}:#{name}"
end

.redisObject



44
45
46
# File 'lib/time_pilot/time_pilot.rb', line 44

def self.redis
  @config.redis_store
end

.register_class(klass) ⇒ Object



6
7
8
9
10
# File 'lib/time_pilot/time_pilot.rb', line 6

def self.register_class(klass)
  @mutex.synchronize do
    @group_classes << klass
  end
end