Sha256: 83a5695a287c0da8912be6b578f3206c0f48c11038c2dd885e6a33ed53838bb8

Contents?: true

Size: 607 Bytes

Versions: 15

Compression:

Stored size: 607 Bytes

Contents

# frozen_string_literal: true

module PUNK
  class View < Service
    include Renderable

    def self.present(**kwargs)
      profile_info("present", kwargs) { run(**kwargs) }
    end

    def process
      raise NotImplemented, "view must provide process method"
    end

    protected

    def on_success
      raise InternalServerError, "not a template: #{result}" unless result.is_a?(String)
      template(result)
    end

    def on_failure
      Fail.run(message: "view failed: #{self.class}", error_messages: errors.full_messages, status: invalid? ? 400 : 500) unless is_a?(Fail)
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
punk-0.4.1 lib/punk/framework/view.rb
punk-0.3.6 lib/punk/framework/view.rb
punk-0.3.5 lib/punk/framework/view.rb
punk-0.3.4 lib/punk/framework/view.rb
punk-0.3.3 lib/punk/framework/view.rb
punk-0.3.2 lib/punk/framework/view.rb
punk-0.3.1 lib/punk/framework/view.rb
punk-0.2.0 lib/punk/framework/view.rb
punk-0.1.4 lib/punk/framework/view.rb
punk-0.1.3 lib/punk/framework/view.rb
punk-0.1.2 lib/punk/framework/view.rb
punk-0.1.0 lib/punk/framework/view.rb
punk-0.0.3 lib/punk/framework/view.rb
punk-0.0.2 lib/punk/framework/view.rb
punk-0.0.1 lib/punk/framework/view.rb