lib/kentouzu/has_drafts.rb in kentouzu-0.1.1 vs lib/kentouzu/has_drafts.rb in kentouzu-0.1.2

- old
+ new

@@ -6,10 +6,12 @@ module ClassMethods def has_drafts(options = {}) send :include, InstanceMethods + send :define_model_callbacks, :draft_save + class_attribute :draft_association_name self.draft_association_name = options[:draft] || :draft attr_accessor self.draft_association_name @@ -103,13 +105,17 @@ :event => self.persisted? ? 'update' : 'create', :source_type => Kentouzu.source.present? ? Kentouzu.source.class.to_s : nil, :source_id => Kentouzu.source.present? ? Kentouzu.source.id : nil, :object => self.to_yaml } - data.merge!(Kentouzu.controller_info || {}) + data.merge!(Kentouzu.controller_info.slice(:item_type, :item_id, :event, :source_type, :source_id) || {}) + draft = Draft.new(data) - draft.save + + run_callbacks :draft_save do + draft.save + end else default_save.bind(self).call end end end