Sha256: d7b235bf9903e3a6a5992bd59e18f6a5ebe8389fc75633483f323f6f43cb1409
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
module Radriar module API module Context def context OpenStruct.new(current_user: current_user) end def id params[:id] end def create_params [permitted_params, create_handlers] end def create_handlers @create_handlers ||= { success: ->(record) { represent(record) }, failure: ->(errors) { error!({ message: "Validation failed", errors: errors }, 422) } } end def update_params [id, permitted_params, update_handlers] end def update_handlers @update_handlers ||= { success: ->(record) { represent(record) }, failure: ->(errors) { error!({ message: "Validation failed", errors: errors }, 422) } } end def success_or_forbidden_handlers @success_of_forbidden_handlers ||= { success: ->(*) { status 200 }, failure: ->(msg) { error!(msg, 403)} } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
radriar-0.1.0.alpha.1 | lib/radriar/api/context.rb |