Investigate and document BSON::Regexp::Raw as a valid field type

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      After some discussion, it seems there are many differences between a BSON::Regexp::Raw type, and a user might want to work explicitly with those types.

      class User
        include Mongoid::Document
      
        field :reg, type: BSON::Regexp::Raw
      end
      
      u = User.create!(reg: BSON::Regexp::Raw.new("hello"))
      p u.reg
      # => #<BSON::Regexp::Raw:0x00007fcfa8317b10 @pattern="hello", @options="", @compiled=/hello/>
      u = User.find(u.id)
      p u.reg
      # => #<BSON::Regexp::Raw:0x00007fcfad2825d8 @pattern="hello", @options="">
      

      This already works. However this ticket could also be used to create a mongoize and demongoize method so that a string/regex assigned to this field can be coerced to a BSON::Regexp::Raw type.

              Assignee:
              Unassigned
              Reporter:
              Neil Shweky (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: