Sha256: 8e75f15eb2e4fa1a194865e7dd72ff669c4623b25539ec75325e85774024ad74

Contents?: true

Size: 1.97 KB

Versions: 9

Compression:

Stored size: 1.97 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class All
# Set: All cards (Error)
#
module Error;
extend Card::Set
def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/standard/set/all/error.rb"; end
def copy_errors card
  card.errors.each do |att, msg|
    errors.add att, msg
  end
end

module Format; parent.send :register_set_format, Card::Format, self; extend Card::Set::AbstractFormat
  view :closed_missing, perms: :none, closed: true do
    ""
  end

  view :missing, perms: :none, cache: :never do
    ""
  end

  view :server_error, perms: :none do
    tr(:server_error)
  end

  view :denial, perms: :none do
    focal? ? tr(:denial) : ""
  end

  view :not_found, perms: :none do
    error_name = card.name.present? ? safe_name : tr(:not_found_no_name)
    tr(:not_found_named, cardname: error_name)
  end

  view :bad_address, perms: :none do
    root.error_status = 404
    tr(:bad_address)
  end

  view :errors do
    ["Problem:", "", standard_errors].flatten.join "\n"
  end

  def standard_errors
    card.errors.map do |attrib, msg|
      attrib == :abort ? msg : standard_error_message(attrib, msg)
    end
  end

  # for override
  def standard_error_message attribute, message
    "#{attribute.to_s.upcase}: #{message}"
  end

  def unsupported_view_error_message view
    tr(:unsupported_view, view: view, cardname: card.name)
  end
end

module JsonFormat; parent.send :register_set_format, Card::Format::JsonFormat, self; extend Card::Set::AbstractFormat
  view :errors do
    format_error error_list
  end

  view :server_error, :errors
  view :denial, :errors
  view :not_found, :errors

  view :bad_address do
    format_error super()
  end

  def format_error error
    { error_status: error_status, errors: error }
  end

  def error_list
    card.errors.each_with_object([]) do |(field, message), list|
      list << { field: field, message: message }
    end
  end
end
end;end;end;end;
# ~~ generated from /Users/ethan/dev/decko/gem/card/mod/standard/set/all/error.rb ~~

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
card-1.99.4 tmpsets/set/mod021-standard/all/error.rb
card-1.99.3 tmpsets/set/mod021-standard/all/error.rb
card-1.99.2 tmpsets/set/mod021-standard/all/error.rb
card-1.99.1 tmpsets/set/mod021-standard/all/error.rb
card-1.99.0 tmpsets/set/mod021-standard/all/error.rb
card-1.98.3 tmpsets/set/mod021-standard/all/error.rb
card-1.98.2 tmpsets/set/mod021-standard/all/error.rb
card-1.98.1 tmpsets/set/mod021-standard/all/error.rb
card-1.98.0 tmpsets/set/mod021-standard/all/error.rb