Class: Mailboxer::BaseBuilder

Inherits:
Object
  • Object
show all
Defined in:
app/builders/mailboxer/base_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ BaseBuilder

Returns a new instance of BaseBuilder.



5
6
7
# File 'app/builders/mailboxer/base_builder.rb', line 5

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

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'app/builders/mailboxer/base_builder.rb', line 3

def params
  @params
end

Instance Method Details

#buildObject



9
10
11
12
13
14
15
# File 'app/builders/mailboxer/base_builder.rb', line 9

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