Module: Card::Set::All::Debug::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod035-monkey/all/debug.rb

Instance Method Summary collapse

Instance Method Details

#always_ok?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'platypus/tmp/set/gem-defaults/mod035-monkey/all/debug.rb', line 15

def always_ok?
  Card::Auth.always_ok?
end

#cache_comparison_table(subject) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'platypus/tmp/set/gem-defaults/mod035-monkey/all/debug.rb', line 59

def cache_comparison_table subject
  cache_card = Card.fetch(subject.key)
  db_card    = Card.find_by_key(subject.key)
  return unless cache_card && db_card

  table(
    %i[name updated_at updater_id content inspect].map do |field|
      [field.to_s,
       h(cache_card.send(field)),
       h(db_card.send(field))]
    end,
    header: ["Field", "Cache Val", "Database Val"]
  )
end

#core_section_config(subject) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'platypus/tmp/set/gem-defaults/mod035-monkey/all/debug.rb', line 19

def core_section_config subject
  [["Sets", tabs("set modules" => set_modules_accordion(subject),
                 "all modules" => singleton_modules_list(subject),
                 "patterns" => set_patterns_breadcrumb(subject))],
   ["Views", tabs("by format" => subformat(subject)._render_views_by_format,
                  "by name" => subformat(subject)._render_views_by_name)],
   ["Events", tabs(create: "<pre>#{subject.events(:create)}</pre>",
                   update: "<pre>#{subject.events(:update)}</pre>",
                   delete: "<pre>#{subject.events(:delete)}</pre>")],
   ["Cache/DB Comparison", cache_comparison_table(subject)]]
end

#set_module_ancestor_hash(subject) ⇒ Object



40
41
42
43
44
45
46
# File 'platypus/tmp/set/gem-defaults/mod035-monkey/all/debug.rb', line 40

def set_module_ancestor_hash subject
  subject.set_modules.each_with_object({}) do |sm, hash|
    ans = sm.ancestors
    ans.shift
    hash[sm.to_s] = ans if ans.present?
  end
end

#set_modules_accordion(subject) ⇒ Object



31
32
33
34
35
36
37
38
# File 'platypus/tmp/set/gem-defaults/mod035-monkey/all/debug.rb', line 31

def set_modules_accordion subject
  accordion do
    set_module_ancestor_hash(subject).each_with_object([]) do |(setmod, anc), array|
      context = setmod.to_name.key
      array << accordion_item(setmod, body: list_group(anc), context: context)
    end
  end
end

#set_patterns_breadcrumb(subject) ⇒ Object



48
49
50
51
# File 'platypus/tmp/set/gem-defaults/mod035-monkey/all/debug.rb', line 48

def set_patterns_breadcrumb subject
  links = subject.patterns.reverse.map { |pattern| link_to_card pattern.to_s }
  breadcrumb links
end

#singleton_modules_list(subject) ⇒ Object



53
54
55
56
57
# File 'platypus/tmp/set/gem-defaults/mod035-monkey/all/debug.rb', line 53

def singleton_modules_list subject
  all_mods = subject.singleton_class.ancestors.map(&:to_s)
  all_mods.shift
  list_group all_mods
end

#view: debugObject



9
10
11
12
13
# File 'platypus/tmp/set/gem-defaults/mod035-monkey/all/debug.rb', line 9

view :debug, perms: :always_ok? do
  core_section_config(card).map do |item|
    section(*item)
  end
end