class SitePrism::AllThere::RecursionChecker

Recurse through all of the objects found on an individual Page/Section Perform the all_there? check according to what recursion level is specified

Attributes

instance[R]

Public Class Methods

new(instance) click to toggle source
# File lib/site_prism/all_there/recursion_checker.rb, line 11
def initialize(instance)
  @instance = instance
end

Public Instance Methods

all_there?(recursion: :one) click to toggle source

@return [Boolean] This currently defaults to perform a recursion of depth :one It will be refactored to use either no input, :none, or :one as the regular repo uses currently

# File lib/site_prism/all_there/recursion_checker.rb, line 19
def all_there?(recursion: :one)
  if recursion == :one || SitePrism.recursion_setting == :one
    current_class_all_there? &&
      section_classes_all_there? &&
      sections_classes_all_there?
  else
    current_class_all_there?
  end
end

Private Instance Methods

current_class_all_there?() click to toggle source

@return [Boolean] Are all SitePrism objects that exist in self present?

# File lib/site_prism/all_there/recursion_checker.rb, line 33
def current_class_all_there?
  expected_items.array.flatten.all? { |name| there?(name) }.tap do |result|
    SitePrism.logger.info("Result of current_class_all_there?: #{result}")
  end
end
expected_items() click to toggle source
# File lib/site_prism/all_there/recursion_checker.rb, line 63
def expected_items
  @expected_items ||= ExpectedItems.new(instance)
end
section_classes_all_there?() click to toggle source

@return [Boolean] Are all SitePrism objects that exist in all self.section items present?

# File lib/site_prism/all_there/recursion_checker.rb, line 41
def section_classes_all_there?
  section_classes_to_check.all?(&:all_there?).tap do |result|
    SitePrism.logger.debug("Result of section_classes_all_there?: #{result}")
  end
end
section_classes_to_check() click to toggle source
# File lib/site_prism/all_there/recursion_checker.rb, line 55
def section_classes_to_check
  expected_items.section.map { |name| instance.send(name) }
end
sections_classes_all_there?() click to toggle source

@return [Boolean] Are all SitePrism objects that exist in all self.sections items present?

# File lib/site_prism/all_there/recursion_checker.rb, line 49
def sections_classes_all_there?
  sections_classes_to_check.flatten.all?(&:all_there?).tap do |result|
    SitePrism.logger.debug("Result of section_classes_all_there?: #{result}")
  end
end
sections_classes_to_check() click to toggle source
# File lib/site_prism/all_there/recursion_checker.rb, line 59
def sections_classes_to_check
  expected_items.sections.map { |name| instance.send(name) }
end
there?(name) click to toggle source
# File lib/site_prism/all_there/recursion_checker.rb, line 67
def there?(name)
  instance.send("has_#{name}?")
end