Module: Card::Machine

Defined in:
lib/card/machine.rb

Constant Summary collapse

REFRESHED =
"MACHINE_ASSETS_REFRESHED".freeze

Class Method Summary collapse

Class Method Details

.refresh_asset(asset_type, force) ⇒ Object



38
39
40
# File 'lib/card/machine.rb', line 38

def refresh_asset asset_type, force
  all_rule(asset_type)&.refresh_output force: force
end

.refresh_assets(force: false) ⇒ Object



6
7
8
9
10
11
# File 'lib/card/machine.rb', line 6

def refresh_assets force: false
  return unless force || refresh_assets?

  refresh_asset :script, force
  refresh_asset :style, force
end

.refresh_assets!Object



13
14
15
# File 'lib/card/machine.rb', line 13

def refresh_assets!
  refresh_assets force: true
end

.reset_allObject



17
18
19
20
21
22
23
24
25
# File 'lib/card/machine.rb', line 17

def reset_all
  Auth.as_bot do
    Card.search(right: { codename: "machine_output" }).each do |card|
      card.update_columns trash: true
      card.expire
    end
  end
  reset_virtual_machine_cache
end

.reset_scriptObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/card/machine.rb', line 27

def reset_script
  Auth.as_bot do
    card = Card[:all, :script, :machine_output]
    if card
      card.update_columns trash: true
      card.expire
      reset_virtual_machine_cache
    end
  end
end