Sha256: f5a747ec1bf723c8f78a5b2c57d5d78ff2a113da345b6eed41a203c991f47ad4

Contents?: true

Size: 700 Bytes

Versions: 2

Compression:

Stored size: 700 Bytes

Contents

require 'aldous/simple_dto'

module Aldous
  class ViewBuilder
    attr_reader :view_context, :default_view_data

    def initialize(view_context, default_view_data)
      @view_context = view_context
      @default_view_data = default_view_data
    end

    def build(respondable_class, extra_view_data = {}, status = nil)
      actual_status = status || extra_view_data[:status]
      extra_view_data_no_status = extra_view_data.reject{|k, v| k == :status}
      actual_extra_view_data = default_view_data.merge(extra_view_data_no_status)
      view_data_dto = Aldous::SimpleDto.new(actual_extra_view_data)

      respondable_class.new(actual_status, view_data_dto, view_context)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aldous-1.1.3 lib/aldous/view_builder.rb
aldous-1.1.2 lib/aldous/view_builder.rb