Module: PaperclipLambda::ClassMethods

Defined in:
lib/paperclip_lambda.rb

Instance Method Summary collapse

Instance Method Details

#paperclip_definitionsObject



31
32
33
34
35
# File 'lib/paperclip_lambda.rb', line 31

def paperclip_definitions
  @paperclip_definitions ||= if respond_to? :attachment_definitions
    attachment_definitions
  end
end

#process_delete_in_lambda(attachment_name, options = {}) ⇒ Object



27
28
29
# File 'lib/paperclip_lambda.rb', line 27

def process_delete_in_lambda(attachment_name, options = {})
  PaperclipLambda::Client.new(paperclip_definitions[:"#{attachment_name}"][:lambda][:function_name], options)
end

#process_in_lambda(name, function_name, options = { }) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/paperclip_lambda.rb', line 15

def process_in_lambda(name, function_name, options = { })
  paperclip_definitions[name][:lambda] = { }
  paperclip_definitions[name][:lambda][:function_name] = function_name
  paperclip_definitions[name][:lambda][:attributes] = options[:attributes] || []

  if respond_to?(:after_commit)
    after_commit :enqueue_lambda_processing
  else
    after_save :enqueue_lambda_processing
  end
end