Sha256: fa0b0cfa34cf56e2d6127f4525ccb32d003b16f85ce27e370bffdd6ecbe07282
Contents?: true
Size: 745 Bytes
Versions: 15
Compression:
Stored size: 745 Bytes
Contents
# frozen_string_literal: true module PUNK class Action < Service def self.perform(**kwargs) action = profile_info("perform", kwargs) { run(**kwargs) } action.result end def process raise NotImplemented, "action must provide process method" end def present(view_class, **kwargs) raise InternalServerError, "not a view: #{view_class}" unless view_class < View view_class.run(**kwargs) end protected def on_success raise InternalServerError, "not a view: #{result}" unless result.is_a?(View) end def on_failure @_result = Fail.run(message: "action failed: #{self.class}", error_messages: errors.full_messages, status: invalid? ? 400 : 500) end end end
Version data entries
15 entries across 15 versions & 1 rubygems