class Sheriff::FeatureSet

Attributes

context[RW]
name[R]

Public Class Methods

all() click to toggle source
# File lib/sheriff/feature_set.rb, line 45
def self.all
  Sheriff.defined_feature_sets
end
define(feature_set_name) { |new_feature_set| ... } click to toggle source
# File lib/sheriff/feature_set.rb, line 27
def self.define(feature_set_name)
  if self.defined? feature_set_name
    raise Sheriff::FeatureSet::AlreadyDefinedError.new("Feature Set #{feature_set_name} already defined")
  end

  new_feature_set = Sheriff::FeatureSet.new(feature_set_name)
  Sheriff.defined_feature_sets << new_feature_set
  yield(new_feature_set) if block_given?
end
defined?(feature_set_name) click to toggle source
# File lib/sheriff/feature_set.rb, line 37
def self.defined?(feature_set_name)
  Sheriff.defined_feature_sets.map(&:name).include?(feature_set_name)
end
find(name) click to toggle source
# File lib/sheriff/feature_set.rb, line 41
def self.find(name)
  Sheriff.defined_feature_sets.select {|fs| fs.name == name}.first
end
new(name) click to toggle source
# File lib/sheriff/feature_set.rb, line 8
def initialize(name)
  @name = name
  @jurisdiction = Sheriff::Jurisdiction.new()
end

Public Instance Methods

hide(*args) click to toggle source
# File lib/sheriff/feature_set.rb, line 13
def hide(*args)
  @jurisdiction.hide *args
end
show(*args) click to toggle source
# File lib/sheriff/feature_set.rb, line 17
def show(*args)
  @jurisdiction.show *args
end
visible?() click to toggle source
# File lib/sheriff/feature_set.rb, line 21
def visible?
  caller.first.match /`(.+)'$/
  context_method = $1
  @jurisdiction.can? context_method.to_sym, @context
end