Sha256: e8fc8749d1a1c8dd24c6063762b0c5a6a543567b03698082682fcd7b6fc38e1c

Contents?: true

Size: 915 Bytes

Versions: 20

Compression:

Stored size: 915 Bytes

Contents

module Grape
  module Util
    class InheritableValues
      attr_accessor :inherited_values
      attr_accessor :new_values

      def initialize(inherited_values = {})
        self.inherited_values = inherited_values
        self.new_values = {}
      end

      def [](name)
        values[name]
      end

      def []=(name, value)
        new_values[name] = value
      end

      def delete(key)
        new_values.delete key
      end

      def merge(new_hash)
        values.merge(new_hash)
      end

      def keys
        (new_values.keys + inherited_values.keys).sort.uniq
      end

      def to_hash
        values.clone
      end

      def initialize_copy(other)
        super
        self.inherited_values = other.inherited_values
        self.new_values = other.new_values.dup
      end

      protected

      def values
        @inherited_values.merge(@new_values)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
grape-1.2.4 lib/grape/util/inheritable_values.rb
grape-1.2.3 lib/grape/util/inheritable_values.rb
grape-1.2.2 lib/grape/util/inheritable_values.rb
grape-1.2.1 lib/grape/util/inheritable_values.rb
grape-1.2.0 lib/grape/util/inheritable_values.rb
grape-1.1.0 lib/grape/util/inheritable_values.rb
grape-1.0.3 lib/grape/util/inheritable_values.rb
grape-1.0.2 lib/grape/util/inheritable_values.rb
grape-1.0.1 lib/grape/util/inheritable_values.rb
grape-1.0.0 lib/grape/util/inheritable_values.rb
grape-0.19.2 lib/grape/util/inheritable_values.rb
grape-0.19.1 lib/grape/util/inheritable_values.rb
grape-0.19.0 lib/grape/util/inheritable_values.rb
grape-0.18.0 lib/grape/util/inheritable_values.rb
grape-0.17.0 lib/grape/util/inheritable_values.rb
grape-0.16.2 lib/grape/util/inheritable_values.rb
grape-0.16.1 lib/grape/util/inheritable_values.rb
grape-0.15.0 lib/grape/util/inheritable_values.rb
grape-0.14.0 lib/grape/util/inheritable_values.rb
grape-0.13.0 lib/grape/util/inheritable_values.rb