Class: Dipswitch::Feature
- Inherits:
-
Object
- Object
- Dipswitch::Feature
- Defined in:
- lib/dipswitch/feature.rb
Instance Attribute Summary collapse
-
#gate ⇒ Object
readonly
Returns the value of attribute gate.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #==(o) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name, gate = nil, &block) ⇒ Feature
constructor
A new instance of Feature.
- #on?(*args) ⇒ Boolean
Constructor Details
#initialize(name, gate = nil, &block) ⇒ Feature
Returns a new instance of Feature.
6 7 8 9 10 11 12 13 14 |
# File 'lib/dipswitch/feature.rb', line 6 def initialize(name, gate = nil, &block) @name = name if block_given? @gate = block else @gate = gate end end |
Instance Attribute Details
#gate ⇒ Object (readonly)
Returns the value of attribute gate.
4 5 6 |
# File 'lib/dipswitch/feature.rb', line 4 def gate @gate end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/dipswitch/feature.rb', line 4 def name @name end |
Instance Method Details
#==(o) ⇒ Object Also known as: eql?
20 21 22 |
# File 'lib/dipswitch/feature.rb', line 20 def ==(o) o.class == self.class && o.name == name && o.gate == gate end |
#hash ⇒ Object
25 26 27 |
# File 'lib/dipswitch/feature.rb', line 25 def hash "#{name}_#{gate.hash}".hash end |
#on?(*args) ⇒ Boolean
16 17 18 |
# File 'lib/dipswitch/feature.rb', line 16 def on?(*args) @gate.call(*args) end |