Sha256: 4e1b8a6481f9b87df9ba4fb890127c5dacd5ceead199c8ed4c68d188a653ade7

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 Bytes

Contents

require 'forwardable'

module FlipFab
  class FeaturesByName
    extend Forwardable

    def initialize features_by_name={}
      @features_by_name = features_by_name
    end

    def [] name
      raise "no feature has been defined with the name: #{name}" if @features_by_name[name].nil?
      @features_by_name[name]
    end

    def with_context context
      FeaturesByName.new Hash[@features_by_name.map{|name, feature| [name, (feature.with_context context)]}]
    end

    def_delegators :@features_by_name, :[]=, :clear, :count
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flip_fab-0.0.1 lib/flip_fab/features_by_name.rb