Class: FeatureCreep::SimpleStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_creep/version.rb,
lib/feature_creep/simple_strategy.rb

Constant Summary collapse

VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.infoObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/feature_creep/simple_strategy.rb', line 4

def self.info
  lambda { |creep,feature|
    if feature
      {
        :percentage => (creep.active_percentage(feature) || 0).to_i,
        :scopes     => creep.active_scopes(feature).map { |g| g.to_sym },
        :agent_ids  => creep.active_agent_ids(feature),
        :global     => creep.active_global_features,
        :available_features => creep.features
      }
    else
      {
        :global     => creep.active_global_features,
        :available_features => creep.features
      }
    end
  }
end

.wardenObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/feature_creep/simple_strategy.rb', line 23

def self.warden
  lambda { |creep,feature,agent_id|
    if agent_id
      creep.active_globally?(feature) ||
        creep.agent_id_in_active_scope?(feature, agent_id) ||
        creep.agent_id_active?(feature, agent_id) ||
        creep.agent_id_within_active_percentage?(feature, agent_id)
    else
      creep.active_globally?(feature)
    end
  }
end