module ErrorChecks

Public Instance Methods

check_error(exception, *args, &block) click to toggle source
# File lib/runeblog.rb, line 40
def check_error(exception, *args, &block)
  # raise if block IS true
  raise send(exception.to_s, *args) if block.call
end
check_integer(num) click to toggle source
# File lib/runeblog.rb, line 31
def check_integer(num)
  confirm(ExpectedInteger, num, num.class) { num.is_a? Integer }
end
check_nonempty_string(str) click to toggle source
# File lib/runeblog.rb, line 23
def check_nonempty_string(str)
  confirm(ExpectedString, str.inspect, str.class) { str.is_a?(String) && ! str.empty? }
end
check_view_parameter(view) click to toggle source
# File lib/runeblog.rb, line 27
def check_view_parameter(view)
  confirm(ExpectedView, view, view.class) { view.is_a?(String) || view.is_a?(RuneBlog::View) }
end
confirm(exception, *args, &block) click to toggle source
# File lib/runeblog.rb, line 35
def confirm(exception, *args, &block)
  # raise if block is NOT true
  raise send(exception.to_s, *args) if ! block.call
end