lib/copyable/copyable_extension.rb in copyable-0.1.2 vs lib/copyable/copyable_extension.rb in copyable-0.2.0
- old
+ new
@@ -47,10 +47,12 @@
# create a brand new, empty model
new_model = model_class.new
# fill in each column of this brand new model according to the
# instructions given in the copyable declaration
column_overrides = options[:override] || {}
+ # merge with global override hash if exists
+ column_overrides = column_overrides.merge(options[:global_override]) if options[:global_override]
Declarations::Columns.execute(main.column_list, original_model, new_model, column_overrides)
# save that sucker!
Copyable::Saver.save!(new_model, options[:skip_validations])
# tell the registry that we've created a new model (the registry
# helps keep us from creating another copy of a model we've
@@ -59,10 +61,10 @@
# for this brand new model, visit all of the associated models,
# making new copies according to the instructions in the copyable
# declaration
skip_associations = options[:skip_associations] || []
- Declarations::Associations.execute(main.association_list, original_model, new_model, options[:skip_validations], skip_associations)
+ Declarations::Associations.execute(main.association_list, original_model, new_model, options[:global_override], options[:skip_validations], skip_associations)
# run the after_copy block if it exists
Declarations::AfterCopy.execute(main.after_copy_block, original_model, new_model)
ensure
# it's critically important to re-enable the callbacks and
# observers or they will stay disabled for future web