Mongoid::Relations::Targets::Enumerable get skipped in case statement

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Done
    • 5.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I wrote a helper method to get attributes hash/hashes out of some known data types like this

      case obj
      when Hash then obj
      when Mongoid::Relations::Targets::Enumerable, 
           Array,
           Mongoid::Criteria then obj.map(&:attrs)
      when Error, Mongoid::Document then obj.attrs
      end
      

      while obj.class == Mongoid::Relations::Targets::Enumerable the second branch get skipped. I dug into the code, found === method had been overridden:

      def ===(other)
        other.class == Class ? Array == other : self == other
      end
      

      such that its instances cannot match it in a case statement.

              Assignee:
              Unassigned
              Reporter:
              kaid
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: