Created
March 5, 2018 08:18
-
-
Save arefaslani/9b2b648cb6b1a306ea2d31157b7bead2 to your computer and use it in GitHub Desktop.
errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Peafowl | |
module Errors | |
class JSONAPI | |
attr_accessor :errors | |
def initialize | |
@errors = [] | |
end | |
def add(options={}) | |
raise StandardError unless options[:title] | |
error = {} | |
options.each do |key, value| | |
error[key.to_sym] = value | |
end | |
@errors << error | |
end | |
def clear | |
@errors = [] | |
end | |
def empty? | |
@errors.empty? | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment