Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Apply suggestions to improve methods' documentation

Co-authored-by: Nicolas Fricke <[email protected]>
  • Loading branch information
aaronsama and nicolas-fricke authored Oct 5, 2023
1 parent 8979030 commit ddf8237
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/rails_cursor_pagination/timestamp_cursor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module RailsCursorPagination
class TimestampCursor < Cursor
class << self
# Decode the provided encoded cursor. Returns an instance of this
# +RailsCursorPagination::Cursor+ class containing both the ID and the
# `RailsCursorPagination::Cursor` class containing both the ID and the
# ordering field value. The ordering field is expected to be a timestamp
# and is always decoded in the UTC timezone.
#
Expand All @@ -17,6 +17,10 @@ class << self
# @param order_field [Symbol]
# The column that is being ordered on. It needs to be a timestamp of a
# class that responds to `#strftime`.
# @raise [RailsCursorPagination::InvalidCursorError]
# In case the given `encoded_string` cannot be decoded properly
# @return [RailsCursorPagination::TimestampCursor]
# Instance of this class with a properly decoded timestamp cursor
def decode(encoded_string:, order_field:)
decoded = JSON.parse(Base64.strict_decode64(encoded_string))

Expand All @@ -35,6 +39,9 @@ def decode(encoded_string:, order_field:)
# Encodes the cursor as an array containing the timestamp as microseconds
# from UNIX epoch and the id of the object
#
# @raise [RailsCursorPagination::ParameterError]
# The order field value needs to respond to `#strftime` to use the
# `TimestampCursor` class. Otherwise, a `ParameterError` is raised.
# @return [String]
def encode
unless @order_field_value.respond_to?(:strftime)
Expand Down

0 comments on commit ddf8237

Please sign in to comment.