class BucketCake::Base::Realtime

Constants

CURSOR_REGEX
DEFAULT_LOOKBACK

Attributes

cursor[R]
keys[R]

Public Class Methods

new(cursor) click to toggle source
# File lib/bucket_cake/base.rb, line 71
def initialize(cursor)
  raise 'Invalid cursor format!' unless cursor.nil? || cursor =~ CURSOR_REGEX
  @cursor = cursor || default_cursor
end

Public Instance Methods

files() click to toggle source
Calls superclass method
# File lib/bucket_cake/base.rb, line 76
def files
  @keys = load_keys
  @cursor = keys.last unless keys.empty?
  super
end

Private Instance Methods

default_cursor() click to toggle source
# File lib/bucket_cake/base.rb, line 86
def default_cursor
  minute_cursor(folder, Time.now - DEFAULT_LOOKBACK)
end
load_keys() click to toggle source
# File lib/bucket_cake/base.rb, line 90
def load_keys
  # return all objects after the cursor timestamp
  bucket.objects(marker: cursor, prefix: "#{folder}/").map(&:key)
end