lib/sn_foil/contexts/create_context.rb in snfoil-0.5.5 vs lib/sn_foil/contexts/create_context.rb in snfoil-0.6
- old
+ new
@@ -68,11 +68,11 @@
options[:action] = :create
options = before_setup_create_object(**options)
options = setup_create_object(**options)
authorize(options[:object], :create?, **options)
options = create_hooks(**options)
- unwrap_object(options[:object])
+ options[:object]
end
def setup_create(**options)
options
end
@@ -125,10 +125,12 @@
end
# This method is private to help protect the order of execution of hooks
def create_hooks(options)
options = before_create_save(**options)
- options = if options[:object].save
+ save_successful = options[:object].save
+ options.merge!(object: unwrap_object(options[:object]))
+ options = if save_successful
after_create_save_success(**options)
else
after_create_save_failure(**options)
end
after_create_save(**options)