Sha256: 9d49944b34c9a20e547e6ffcd5302fb6b8319c284a1bac78e91b5843dc118d00

Contents?: true

Size: 444 Bytes

Versions: 11

Compression:

Stored size: 444 Bytes

Contents

class Mailboxer::BaseBuilder

  attr_reader :params

  def initialize(params)
    @params = params.with_indifferent_access
  end

  def build
    klass.new.tap do |object|
      params.keys.each do |field|
        object.send("#{field}=", get(field)) unless get(field).nil?
      end
    end
  end

  protected

  def get(key)
    respond_to?(key) ? send(key) : params[key]
  end

  def recipients
    Array(params[:recipients]).uniq
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mailboxer-0.15.1 app/builders/mailboxer/base_builder.rb
mailboxer-0.15.0 app/builders/mailboxer/base_builder.rb
mailboxer-0.14.0 app/builders/mailboxer/base_builder.rb
mailboxer-0.13.0 app/builders/mailboxer/base_builder.rb
mailboxer-0.12.5 app/builders/mailboxer/base_builder.rb
mailboxer-0.12.4 app/builders/mailboxer/base_builder.rb
mailboxer-0.12.3 app/builders/mailboxer/base_builder.rb
mailboxer-0.12.2 app/builders/mailboxer/base_builder.rb
mailboxer-0.12.1 app/builders/mailboxer/base_builder.rb
mailboxer-0.12.0 app/builders/mailboxer/base_builder.rb
mailboxer-0.12.0.rc2 app/builders/mailboxer/base_builder.rb