Class: Nova::Common::Features::Feature

Inherits:
Object
  • Object
show all
Includes:
EventHandler
Defined in:
lib/nova/common/features/feature.rb

Overview

The information about the feature that was defined.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EventHandler

included

Constructor Details

#initialize(name, options) ⇒ Feature

Returns a new instance of Feature.



18
19
20
21
22
23
# File 'lib/nova/common/features/feature.rb', line 18

def initialize(name, options)
  @name = name
  @options = options
  @bind = Object.new
  @fake = false
end

Instance Attribute Details

#nameSymbol

The name of the feature.

Returns:

  • (Symbol)


11
12
13
# File 'lib/nova/common/features/feature.rb', line 11

def name
  @name
end

#optionsHash

The options of the feature.

Returns:

  • (Hash)


16
17
18
# File 'lib/nova/common/features/feature.rb', line 16

def options
  @options
end

Instance Method Details

#disable!nil, Object

Disables the feature and runs the :disable event, if it exists.

Returns:

  • (nil, Object)


39
40
41
# File 'lib/nova/common/features/feature.rb', line 39

def disable!
  run(:disable)
end

#enable!nil, Object

Enables the feature and runs the :enable event, if it exists.

Returns:

  • (nil, Object)


31
32
33
# File 'lib/nova/common/features/feature.rb', line 31

def enable!
  run(:enable)
end

#fake!self

Marks this feature as fake. This is not reversable.

Returns:

  • (self)

See Also:



57
58
59
60
# File 'lib/nova/common/features/feature.rb', line 57

def fake!
  @fake = true
  self
end

#fake?Boolean

Whether or not this feature is fake. By fake, it means that it was not created with the defining class as a feature; it does not have any events at all, and its only purpose is to mock the behavior of a real, defined feature.

Returns:

  • (Boolean)


49
50
51
# File 'lib/nova/common/features/feature.rb', line 49

def fake?
  @fake
end