Module: FeatureCop::Whitelist::ClassMethods

Defined in:
lib/feature_cop/whitelist.rb

Instance Method Summary collapse

Instance Method Details

#whitelistObject



21
22
23
# File 'lib/feature_cop/whitelist.rb', line 21

def whitelist
  @whitelist
end

#whitelist=(whitelist) ⇒ Object



25
26
27
# File 'lib/feature_cop/whitelist.rb', line 25

def whitelist=(whitelist)
  @whitelist = whitelist
end

#whitelist_from_yaml(file = "feature_cop_whitelist.yml") ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/feature_cop/whitelist.rb', line 10

def whitelist_from_yaml(file = "feature_cop_whitelist.yml")
  if ::File.exists?(file)
    absolute_path = file       
  elsif defined?(Rails)
    absolute_path = ::File.join(Rails.root, "config", file)
  end

  raise "#{file} not found!" unless ::File.exists?(absolute_path)
  self.whitelist = ::YAML.load_file(absolute_path)[env]      
end

#whitelist_only(identifier) ⇒ Object



29
30
31
# File 'lib/feature_cop/whitelist.rb', line 29

def whitelist_only(identifier)
  whitelisted?(identifier)
end

#whitelisted?(identifier) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/feature_cop/whitelist.rb', line 33

def whitelisted?(identifier)
  return false if @whitelist.nil?
  @whitelist.include?(identifier)
end