Sha256: a911dc9ab0cb3db75236a4c18bb1064ce96257ead9f601174960be3f99eb6947
Contents?: true
Size: 682 Bytes
Versions: 6
Compression:
Stored size: 682 Bytes
Contents
# Copied from the DeepStruct gem # Modified to return Null on unknown key module DeepStruct class HashWrapper < DeepWrapper def method_missing(method, *args, &block) return @value.send(method, *args, &block) if @value.respond_to?(method) method = method.to_s if method.chomp!('?') key = method.to_sym self.has_key?(key) && !!self[key] elsif method.chomp!('=') raise ArgumentError, "wrong number of arguments (#{arg_count} for 1)", caller(1) if args.length != 1 self[method] = args[0] elsif args.length == 0 && self.has_key?(method) self[method] else Hem::Null.new end end end end
Version data entries
6 entries across 6 versions & 1 rubygems