Class: Mongoid::Scroll::Cursor
- Inherits:
-
BaseCursor
- Object
- BaseCursor
- Mongoid::Scroll::Cursor
- Defined in:
- lib/mongoid/scroll/cursor.rb
Instance Attribute Summary
Attributes inherited from BaseCursor
#direction, #field_name, #field_type, #include_current, #tiebreak_id, #value
Instance Method Summary collapse
-
#initialize(value = nil, options = {}) ⇒ Cursor
constructor
A new instance of Cursor.
- #to_s ⇒ Object
Methods inherited from BaseCursor
#criteria, from_record, #sort_options
Constructor Details
#initialize(value = nil, options = {}) ⇒ Cursor
Returns a new instance of Cursor.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/mongoid/scroll/cursor.rb', line 4 def initialize(value = nil, = {}) = () raise ArgumentError.new 'Missing options[:field_name] and/or options[:field_type].' unless if value parts = value.split(':') if value unless parts && parts.length >= 2 raise Mongoid::Scroll::Errors::InvalidCursorError.new(cursor: value) end value = parse_field_value( [:field_type], [:field_name], parts[0...-1].join(':') ) [:tiebreak_id] = BSON::ObjectId.from_string(parts[-1]) super value, else super nil, end end |
Instance Method Details
#to_s ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/mongoid/scroll/cursor.rb', line 24 def to_s tiebreak_id ? [ transform_field_value( field_type, field_name, value ), tiebreak_id ].join(':') : nil end |