lib/bulldog/attachment/base.rb in bulldog-0.0.2 vs lib/bulldog/attachment/base.rb in bulldog-0.0.3
- old
+ new
@@ -19,19 +19,31 @@
end
#
# Run the processors for the named event.
#
- def process(event_name, *args)
+ # Return true if no errors were encountered, false otherwise.
+ #
+ def process(event_name)
reflection.events[event_name].each do |event|
if (types = event.attachment_types)
next unless types.include?(type)
end
processor_type = event.processor_type || default_processor_type
processor_class = Processor.const_get(processor_type.to_s.camelize)
processor = processor_class.new(self, styles_for_event(event), stream.path)
- processor.process(*args, &event.callback)
+ processor.process(&event.callback)
end
+ record.errors.empty?
+ end
+
+ #
+ # Like #process, but raise ActiveRecord::RecordInvalid if there
+ # are any errors.
+ #
+ def process!(event_name, &block)
+ process(event_name, &block) or
+ raise ActiveRecord::RecordInvalid, record
end
#
# Return the path on the file system where the given style's
# image is to be stored.