Sha256: b9b9bcf07962b5955074f969611502fca4e7e9824cee0749bfaf475c3210de6f

Contents?: true

Size: 754 Bytes

Versions: 2

Compression:

Stored size: 754 Bytes

Contents

require 'aldous/simple_dto'

module Aldous
  class BuildRespondableService
    attr_reader :view_context, :default_view_data
    attr_reader :respondable_class, :status, :extra_data

    def initialize(view_context:, default_view_data:, respondable_class:, status: nil, extra_data: {})
      @view_context = view_context
      @default_view_data = default_view_data
      @respondable_class = respondable_class
      @status = status
      @extra_data = extra_data
    end

    def perform
      # we don't need the status as a local
      actual_extra_data = extra_data.reject{|k, v| k == :status}
      view_data = SimpleDto.new(default_view_data.merge(actual_extra_data))
      respondable_class.new(status, view_data, view_context)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aldous-1.0.1 lib/aldous/build_respondable_service.rb
aldous-1.0.0 lib/aldous/build_respondable_service.rb