lib/mongoid/shell/errors/base.rb in mongoid-shell-0.2.0 vs lib/mongoid/shell/errors/base.rb in mongoid-shell-0.3.0

- old
+ new

@@ -1,10 +1,9 @@ module Mongoid module Shell module Errors class Base < StandardError - # Problem occurred. attr_reader :problem # Summary of the problem. attr_reader :summary @@ -19,63 +18,62 @@ def compose_message(key, attributes = {}) @problem = create_problem(key, attributes) @summary = create_summary(key, attributes) @resolution = create_resolution(key, attributes) - "\nProblem:\n #{@problem}"+ - "\nSummary:\n #{@summary}"+ + "\nProblem:\n #{@problem}" \ + "\nSummary:\n #{@summary}" \ "\nResolution:\n #{@resolution}" end private - BASE_KEY = "mongoid.shell.errors.messages" #:nodoc: + BASE_KEY = "mongoid.shell.errors.messages" #:nodoc: - # Given the key of the specific error and the options hash, translate the - # message. - # - # === Parameters - # [key] The key of the error in the locales. - # [options] The objects to pass to create the message. - # - # Returns a localized error message string. - def translate(key, options) - ::I18n.translate("#{BASE_KEY}.#{key}", { :locale => :en }.merge(options)).strip - end + # Given the key of the specific error and the options hash, translate the + # message. + # + # === Parameters + # [key] The key of the error in the locales. + # [options] The objects to pass to create the message. + # + # Returns a localized error message string. + def translate(key, options) + ::I18n.translate("#{BASE_KEY}.#{key}", { locale: :en }.merge(options)).strip + end - # Create the problem. - # - # === Parameters - # [key] The error key. - # [attributes] The attributes to interpolate. - # - # Returns the problem. - def create_problem(key, attributes) - translate("#{key}.message", attributes) - end + # Create the problem. + # + # === Parameters + # [key] The error key. + # [attributes] The attributes to interpolate. + # + # Returns the problem. + def create_problem(key, attributes) + translate("#{key}.message", attributes) + end - # Create the summary. - # - # === Parameters - # [key] The error key. - # [attributes] The attributes to interpolate. - # - # Returns the summary. - def create_summary(key, attributes) - translate("#{key}.summary", attributes) - end + # Create the summary. + # + # === Parameters + # [key] The error key. + # [attributes] The attributes to interpolate. + # + # Returns the summary. + def create_summary(key, attributes) + translate("#{key}.summary", attributes) + end - # Create the resolution. - # - # === Parameters - # [key] The error key. - # [attributes] The attributes to interpolate. - # - # Returns the resolution. - def create_resolution(key, attributes) - translate("#{key}.resolution", attributes) - end - + # Create the resolution. + # + # === Parameters + # [key] The error key. + # [attributes] The attributes to interpolate. + # + # Returns the resolution. + def create_resolution(key, attributes) + translate("#{key}.resolution", attributes) + end end end end end