Sha256: 5f63de7dfaf0e405221e1ee8343a4f40c4279cf2ed0e5cd0331b95b87c100f3d

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

require 'concurrent'

require 'zooniverse_social/posts'
require 'zooniverse_social/statuses'
require 'zooniverse_social/task_observer'

module ZooniverseSocial
  class Data
    def self.posts
      @posts ||= Posts.new
    end

    def self.statuses
      @statuses ||= Statuses.new
    end

    def self.sources
      [posts, statuses]
    end

    def self.current
      {
        posts: posts.data,
        statuses: statuses.data
      }
    end

    def self.update
      sources.each &:update
    end

    def self.start
      task = Concurrent::TimerTask.new(execution_interval: 600, timeout_interval: 20, run_now: true){ update }.execute
      TaskObserver.new task, method(:start)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zooniverse_social-1.3.1 lib/zooniverse_social/data.rb