Module: Nova::Common::Features::InstanceMethods

Extended by:
Forwardable
Included in:
Star
Defined in:
lib/nova/common/features.rb

Overview

Instance methods.

Instance Method Summary collapse

Instance Method Details

#feature(name) ⇒ Feature

Returns a feature that matches the given name. If it doesn’t exist, a fake one is created, and bound to self.

Parameters:

  • name (Symbol)

    the name of the feature.

Returns:



74
75
76
# File 'lib/nova/common/features.rb', line 74

def feature(name)
  features[name]
end

#featuresHash

A hash of features. Any features are bound to this class, after their first access. If a feature is accessed without existing, a fake feature is created and bound to self. All features are cached in the hash after being bound.

Returns:

  • (Hash)

See Also:



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/nova/common/features.rb', line 57

def features
  @_features ||= Hash.new do |hash, key|
    class_feature = self.class.features[key]

    if class_feature
      hash[key] = class_feature.bind(self)
    else
      hash[key] = Feature.new(key, {}).bind(self).fake!
    end
  end
end