I want to define simple global objects that contain a code and
description for custom errors. Is it a bad idea to use structs in an
initializer in the app?
api_error_constants.rb in /config/initializers
error_type = Struct.new(:code, :description)
BAD_JSON = error_type.new("001" , "Problem parsing JSON")
BAD_XML = error_type.new("002" , "Problem parsing XML")
...
...
Or is there a more appropriate/standard way?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment