Module: Nova::Common::Features::InstanceMethods
Overview
Instance methods.
Instance Method Summary collapse
-
#feature(name) ⇒ Feature
Returns a feature that matches the given name.
-
#features ⇒ Hash
A hash of features.
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.
74 75 76 |
# File 'lib/nova/common/features.rb', line 74 def feature(name) features[name] end |
#features ⇒ Hash
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.
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 |