class Josh::Messages
Attributes
setter and getter varibules
setter and getter varibules
setter and getter varibules
setter and getter varibules
setter and getter varibules
setter and getter varibules
setter and getter varibules
Public Class Methods
initialize method
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @return [Object] @param [String] lang
# File lib/respond.rb, line 15 def initialize(lang = :en) I18n.default_locale = lang end
Public Instance Methods
Database connection is refused
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @return [Object]
# File lib/respond.rb, line 143 def connection_refused self.set_status_code(445) .set_status_text('failed') .set_error_code(5445) .respond_with_message end
Delete action is failed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @param [String] message @return [Object]
# File lib/respond.rb, line 90 def delete_failed(message = nil) if message == nil message = I18n.t "respond.failed.delete" end self.set_status_code(447) .set_status_text('failed') .set_error_code(5447) .respond_with_message(message) end
Delete action is succeed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @param [String] message @return [Object]
# File lib/respond.rb, line 39 def delete_succeeded(message = nil) if message == nil message = I18n.t "respond.success.delete" end self.set_status_code(200) .set_status_text('success') .respond_with_message(message) end
Insert action is failed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @param [String] message @return [Object]
# File lib/respond.rb, line 126 def insert_failed(message = nil) if message == nil message = I18n.t "respond.failed.insert" end self.set_status_code(448) .set_status_text('failed') .set_error_code(5448) .respond_with_message(message) end
Insert action is succeed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @param [String] message @return [Object]
# File lib/respond.rb, line 73 def insert_succeeded(message = nil) if message == nil message = I18n.t "respond.success.insert" end self.set_status_code(200) .set_status_text('success') .respond_with_message(message) end
Method is not allowed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @return [Object]
# File lib/respond.rb, line 182 def method_not_allowed self.set_status_code(405) .set_status_text('failed') .set_error_code(5405) .respond_with_message end
Page requested is not found
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @return [Object]
# File lib/respond.rb, line 156 def not_found self.set_status_code(404) .set_status_text('failed') .set_error_code(5404) .respond_with_message end
The request field is duplicated
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @return [Object]
# File lib/respond.rb, line 221 def request_field_duplicated self.set_status_code(400) .set_status_text('failed') .set_error_code(1004) .respond_with_message end
The request field is not found
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @return [Object]
# File lib/respond.rb, line 208 def request_field_notfound self.set_status_code(446) .set_status_text('failed') .set_error_code(1001) .respond_with_message end
Request succeeded and contains json result
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @param [Object] data @return [Object]
# File lib/respond.rb, line 26 def succeed(data) self.set_status_code(200) .set_status_text('success') .respond_with_result(data) end
Update action is succeed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @param [String] message @return [Object]
# File lib/respond.rb, line 108 def update_failed(message = nil) if message == nil message = I18n.t "respond.failed.update" end self.set_status_code(449) .set_status_text('failed') .set_error_code(5449) .respond_with_message(message) end
Update action is succeed
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @param [String] message @return [Object]
# File lib/respond.rb, line 56 def update_succeeded(message = nil) if message == nil message = I18n.t "respond.success.update" end self.set_status_code(200) .set_status_text('success') .respond_with_message(message) end
There ara validation errors
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @return [Object]
# File lib/respond.rb, line 195 def validation_errors(message = nil) self.set_status_code(420) .set_status_text('failed') .set_error_code(5420) .respond_with_message(message) end
Wrong parameters are entered
@author Alireza Josheghani <josheghani.dev@gmail.com> @since 1 Dec 2016 @return [Object]
# File lib/respond.rb, line 169 def wrong_parameters self.set_status_code(406) .set_status_text('failed') .set_error_code(5406) .respond_with_message end