module Nova::Common::Features::InstanceMethods

Instance methods.

Public Instance Methods

feature(name) click to toggle source

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

@param name [Symbol] the name of the feature. @return [Feature]

# File lib/nova/common/features.rb, line 74
def feature(name)
  features[name]
end
features() click to toggle source

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.

@see Features::ClassMethods#features @return [Hash]

# 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