class StatusPageRuby::Services::PullStatuses
Attributes
status_repository[R]
Public Class Methods
new(status_repository)
click to toggle source
# File lib/status_page_ruby/services/pull_statuses.rb, line 6 def initialize(status_repository) @status_repository = status_repository end
Public Instance Methods
call()
click to toggle source
# File lib/status_page_ruby/services/pull_statuses.rb, line 10 def call fetch_statuses.tap do |statuses| status_repository.create_batch(statuses) unless statuses.empty? end end
Private Instance Methods
build_status(page)
click to toggle source
# File lib/status_page_ruby/services/pull_statuses.rb, line 34 def build_status(page) StatusPageRuby::Status.new( page.class.name.split('::').last, page.success? ? 'up' : 'down', page.status, page.time ) end
fetch_statuses()
click to toggle source
# File lib/status_page_ruby/services/pull_statuses.rb, line 18 def fetch_statuses page_classes .map(&:open) .map(&method(:build_status)) end
page_class?(klass)
click to toggle source
# File lib/status_page_ruby/services/pull_statuses.rb, line 30 def page_class?(klass) klass < ::StatusPageRuby::Pages::Base end
page_classes()
click to toggle source
# File lib/status_page_ruby/services/pull_statuses.rb, line 24 def page_classes ObjectSpace .each_object(Class) .select(&method(:page_class?)) end