Module: SimpleAttachments::ContainerModel::InstanceMethods

Defined in:
lib/simple_attachments/container_model.rb

Instance Method Summary collapse

Instance Method Details

#add_attachment(method, attachment) ⇒ Object

:nodoc:



44
45
46
47
48
49
50
51
52
# File 'lib/simple_attachments/container_model.rb', line 44

def add_attachment(method, attachment) # :nodoc:
  if reflections[method.to_sym].instance_variable_get :@collection
    send(method) << attachment
  else
    old_attachment = send(method)
    old_attachment.destroy unless old_attachment.nil?
    send (method + '='), attachment
  end
end