Class: Sheriff::FeatureSet
- Inherits:
-
Object
- Object
- Sheriff::FeatureSet
show all
- Defined in:
- lib/sheriff/errors.rb,
lib/sheriff/feature_set.rb
Defined Under Namespace
Classes: AlreadyDefinedError
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of FeatureSet.
8
9
10
11
|
# File 'lib/sheriff/feature_set.rb', line 8
def initialize(name)
@name = name
@jurisdiction = Sheriff::Jurisdiction.new()
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
6
7
8
|
# File 'lib/sheriff/feature_set.rb', line 6
def context
@context
end
|
#name ⇒ Object
Returns the value of attribute name.
5
6
7
|
# File 'lib/sheriff/feature_set.rb', line 5
def name
@name
end
|
Class Method Details
.define(feature_set_name) {|new_feature_set| ... } ⇒ Object
.defined?(feature_set_name) ⇒ Boolean
37
38
39
|
# 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) ⇒ Object
41
42
43
|
# File 'lib/sheriff/feature_set.rb', line 41
def self.find(name)
Sheriff.defined_feature_sets.select {|fs| fs.name == name}.first
end
|
Instance Method Details
#hide(*args) ⇒ Object
13
14
15
|
# File 'lib/sheriff/feature_set.rb', line 13
def hide(*args)
@jurisdiction.hide *args
end
|
#show(*args) ⇒ Object
17
18
19
|
# File 'lib/sheriff/feature_set.rb', line 17
def show(*args)
@jurisdiction.show *args
end
|
#visible? ⇒ Boolean
21
22
23
24
25
|
# File 'lib/sheriff/feature_set.rb', line 21
def visible?
caller.first.match /`(.+)'$/
context_method = $1
@jurisdiction.can? context_method.to_sym, @context
end
|