Class: Dipswitch::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/dipswitch/feature.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#gateObject (readonly)

Returns the value of attribute gate.



4
5
6
# File 'lib/dipswitch/feature.rb', line 4

def gate
  @gate
end

#nameObject (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

#hashObject



25
26
27
# File 'lib/dipswitch/feature.rb', line 25

def hash
  "#{name}_#{gate.hash}".hash
end

#on?(*args) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/dipswitch/feature.rb', line 16

def on?(*args)
  @gate.call(*args)
end