Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1312

problem with Hash and custom types

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.3.1
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      as you can see in the following example, when I call the [] operator with a key that is not present in the hash an error is raised

      ruby-1.9.2-p180 :020 > class MyHash < ::Hash; include Mongoid::Fields::Serializable; end
      => MyHash
      ruby-1.9.2-p180 :021 > h = MyHash.new
      => {}
      ruby-1.9.2-p180 :022 > h["do-not-exist"]
      ArgumentError: wrong number of arguments (1 for 0)
      from (irb):22:in `[]'
      from (irb):22
      from /usr/local/rvm/rubies/ruby-1.9.2-p180/bin/irb:16:in `<main>'
      ruby-1.9.2-p180 :023 > h["do-not-exist"] = 1
      => 1
      ruby-1.9.2-p180 :024 > h["do-not-exist"]
      => 1

            Assignee:
            Unassigned Unassigned
            Reporter:
            dcu David Cuadrado
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: