Class: FlipFab::FeaturesByName
- Inherits:
-
Object
- Object
- FlipFab::FeaturesByName
- Extended by:
- Forwardable
- Defined in:
- lib/flip_fab/features_by_name.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
-
#initialize(features_by_name = {}) ⇒ FeaturesByName
constructor
A new instance of FeaturesByName.
- #with_context(context) ⇒ Object
Constructor Details
#initialize(features_by_name = {}) ⇒ FeaturesByName
Returns a new instance of FeaturesByName.
7 8 9 |
# File 'lib/flip_fab/features_by_name.rb', line 7 def initialize(features_by_name = {}) @features_by_name = features_by_name end |
Instance Method Details
#[](name) ⇒ Object
11 12 13 14 15 |
# File 'lib/flip_fab/features_by_name.rb', line 11 def [](name) raise "no feature has been defined with the name: #{name}" if @features_by_name[name].nil? @features_by_name[name] end |
#with_context(context) ⇒ Object
17 18 19 |
# File 'lib/flip_fab/features_by_name.rb', line 17 def with_context(context) FeaturesByName.new Hash[@features_by_name.map { |name, feature| [name, (feature.with_context context)] }] end |