mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-17 06:35:14 +08:00
28 lines
544 B
Ruby
28 lines
544 B
Ruby
|
module ClientApi
|
||
|
class BaseService
|
||
|
attr_accessor :current_user, :params
|
||
|
|
||
|
def initialize(args)
|
||
|
@current_user = args.fetch(:current_user) { raise StandardError }
|
||
|
@params = (args.fetch(:params) { {} }).dup
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def error(message, http_status = nil)
|
||
|
result = {
|
||
|
message: message,
|
||
|
status: :error
|
||
|
}
|
||
|
|
||
|
result[:http_status] = http_status if http_status
|
||
|
result
|
||
|
end
|
||
|
|
||
|
def success(pass_back = {})
|
||
|
pass_back[:status] = :success
|
||
|
pass_back
|
||
|
end
|
||
|
end
|
||
|
end
|