Sha256: 0087382cebc189cf7c504c84e2c14aef87e929d3e03b99ba18b057fa2df70855
Contents?: true
Size: 1000 Bytes
Versions: 1
Compression:
Stored size: 1000 Bytes
Contents
# frozen_string_literal: true module Grape module Util # Base for classes which need to operate with own values kept # in the hash and inherited values kept in a Hash-like object. class BaseInheritable attr_accessor :inherited_values attr_accessor :new_values # @param inherited_values [Object] An object implementing an interface # of the Hash class. def initialize(inherited_values = {}) @inherited_values = inherited_values @new_values = {} end def delete(key) new_values.delete key end def initialize_copy(other) super self.inherited_values = other.inherited_values self.new_values = other.new_values.dup end def keys combined = inherited_values.keys combined.concat(new_values.keys) combined.uniq! combined end def key?(name) inherited_values.key?(name) || new_values.key?(name) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-1.3.1 | lib/grape/util/base_inheritable.rb |