Sha256: 5054b2dab8de9486061914ee9f174741cbf63ca948dbcabd2477303663eb1fc6

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

require 'aldous/view_builder'
require 'aldous/simple_dto'

module Aldous
  module Respondable
    class Base
      attr_reader :view_data, :view_context

      def initialize(status, view_data, view_context, view_builder = nil)
        @status = status
        @view_data = view_data
        @view_context = view_context
        @view_builder = view_builder
      end

      def action(controller)
        raise Errors::UserError.new("Respondables must define an 'action' method")
      end

      def status
        @status || default_status
      end

      def default_status
        :ok
      end

      def view_builder
        @view_builder ||= ViewBuilder.new(view_context, view_data._data)
      end

      ################################################
      # NOTE deprecated
      ################################################
      def build_view(respondable_class, extra_data = {}) # deprecated
        view_builder.build(respondable_class, extra_data)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aldous-1.1.3 lib/aldous/respondable/base.rb
aldous-1.1.2 lib/aldous/respondable/base.rb