Sha256: e285aea899bb9ea692d0980725e0239b6fef91805b9df68a5ebff5763bca21f6

Contents?: true

Size: 493 Bytes

Versions: 10

Compression:

Stored size: 493 Bytes

Contents

module A9n
  class Struct
    extend Forwardable

    def_delegators :data, :empty?, :keys, :key?, :fetch, :[], :[]=

    def initialize(data = {})
      @data = data
    end

    def to_hash
      data
    end

    def merge(another_data)
      data.merge!(another_data)
    end

    def method_missing(name, *args)
      if data.key?(name)
        fetch(name)
      else
        fail NoSuchConfigurationVariableError.new(name)
      end
    end

    private

    attr_reader :data
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
a9n-0.6.2 lib/a9n/struct.rb
a9n-0.6.1 lib/a9n/struct.rb
a9n-0.6.0 lib/a9n/struct.rb
a9n-0.5.7 lib/a9n/struct.rb
a9n-0.5.6 lib/a9n/struct.rb
a9n-0.5.5 lib/a9n/struct.rb
a9n-0.5.4 lib/a9n/struct.rb
a9n-0.5.2 lib/a9n/struct.rb
a9n-0.5.1 lib/a9n/struct.rb
a9n-0.5.0 lib/a9n/struct.rb