Module: Card::Format::Error

Included in:
Card::Format
Defined in:
lib/card/format/error.rb

Overview

permissions and errors in card format classes

Instance Method Summary collapse

Instance Method Details

#anyone_can?(task) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
# File 'lib/card/format/error.rb', line 10

def anyone_can? task
  return false unless task.is_a? Symbol

  @anyone_can ||= {}
  @anyone_can[task] = card.anyone_can? task if @anyone_can[task].nil?
  @anyone_can[task]
end

#monitor_depthObject



33
34
35
36
37
38
39
40
# File 'lib/card/format/error.rb', line 33

def monitor_depth
  max = Card.config.max_depth
  if depth >= max || voo.depth >= max
    raise Card::Error::UserError, t(:format_too_deep)
  end

  yield
end

#ok?(task) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
8
# File 'lib/card/format/error.rb', line 5

def ok? task
  task = :create if task == :update && card.new_card?
  card.ok? task
end

#view_for_denial(view, task) ⇒ Object



27
28
29
30
31
# File 'lib/card/format/error.rb', line 27

def view_for_denial view, task
  @denied_task = task
  root.error_status = 403 if focal? && voo.root?
  view_setting(:denial, view) || :denial
end

#view_for_unknown(setting_view) ⇒ Object



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

def view_for_unknown setting_view
  if main? && voo.root?
    root.error_status = page_status_for_unknown
    page_view_for_unknown
  else
    setting_view || :unknown
  end
end