Sha256: 77987bc70388f54b841a8ff5b5ad63ea5be6bf6522e3eb645d67259b902617e3

Contents?: true

Size: 704 Bytes

Versions: 8

Compression:

Stored size: 704 Bytes

Contents

require 'deepstruct'

# 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
        Hobo::Null.new
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hobo-inviqa-0.0.9.pre.rc1 lib/hobo/patches/deepstruct.rb
hobo-inviqa-0.0.9.pre.alpha lib/hobo/patches/deepstruct.rb
hobo-inviqa-0.0.8 lib/hobo/patches/deepstruct.rb
hobo-inviqa-0.0.7.pre.rc3 lib/hobo/patches/deepstruct.rb
hobo-inviqa-0.0.7.pre.rc2 lib/hobo/patches/deepstruct.rb
hobo-inviqa-0.0.7.pre.rc1 lib/hobo/patches/deepstruct.rb
hobo-inviqa-0.0.7 lib/hobo/patches/deepstruct.rb
hobo-inviqa-0.0.6 lib/hobo/patches/deepstruct.rb