Module: Card::Set::All::Actify
- Extended by:
- Card::Set
- Defined in:
- tmpsets/set/mod002-core/all/actify.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary
Constants included from Format
Instance Method Summary collapse
-
#abort(status, msg = "action canceled") ⇒ Object
The Card#abort method is for cleanly exiting an action without continuing to process any further events.
- #abortable ⇒ Object
- #save ⇒ Object
- #save! ⇒ Object
- #success ⇒ Object
- #update_attributes(*args) ⇒ Object
- #update_attributes!(*args) ⇒ Object
- #valid? ⇒ Boolean
-
#with_transaction_returning_status ⇒ Object
this is an override of standard rails behavior that rescues abort makes it so that :success abortions do not rollback.
Methods included from I18nScope
Methods included from Loader
#clean_empty_module_from_hash, #clean_empty_modules, #extended, #process_base_modules, #register_set
Methods included from Helpers
#abstract_set?, #all_set?, #num_set_parts, #shortname, #underscore
Methods included from Card::Set::AdvancedApi
#attachment, #ensure_set, #stage_method
Methods included from Format
#all_set_format_mod!, #before, #define_on_format, #format, layout_method_name, #register_set_format, #view, #view_for_override, view_method_name, wrapper_method_name
Methods included from Inheritance
#include_set, #include_set_formats
Methods included from Basket
#abstract_basket, #add_to_basket, #basket
Methods included from Trait
#card_accessor, #card_reader, #card_writer, #require_field
Methods included from Event::Api
Instance Method Details
#abort(status, msg = "action canceled") ⇒ Object
The Card#abort method is for cleanly exiting an action without continuing to process any further events.
Three statuses are supported:
failure: adds an error, returns false on save success: no error, returns true on save triumph: similar to success, but if called on a subcard it causes the entire action to abort (not just the subcard)
14 15 16 17 18 19 20 21 22 23 |
# File 'tmpsets/set/mod002-core/all/actify.rb', line 14 def abort status, msg="action canceled" director.abort if status == :failure && errors.empty? errors.add :abort, msg elsif status.is_a?(Hash) && status[:success] success << status[:success] status = :success end raise Card::Error::Abort.new(status, msg) end |
#abortable ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'tmpsets/set/mod002-core/all/actify.rb', line 63 def abortable yield rescue Card::Error::Abort => e if e.status == :triumph @supercard ? raise(e) : true elsif e.status == :success if @supercard @supercard.subcards.delete key @supercard.director.subdirectors.delete self expire_soft end true end end |
#save ⇒ Object
47 48 49 |
# File 'tmpsets/set/mod002-core/all/actify.rb', line 47 def save(*) act { super } end |
#save! ⇒ Object
43 44 45 |
# File 'tmpsets/set/mod002-core/all/actify.rb', line 43 def save!(*) act { super } end |
#success ⇒ Object
95 96 97 |
# File 'tmpsets/set/mod002-core/all/actify.rb', line 95 def success Env.success(cardname) end |
#update_attributes(*args) ⇒ Object
55 56 57 |
# File 'tmpsets/set/mod002-core/all/actify.rb', line 55 def update_attributes *args act(*args) { super } end |
#update_attributes!(*args) ⇒ Object
59 60 61 |
# File 'tmpsets/set/mod002-core/all/actify.rb', line 59 def update_attributes! *args act(*args) { super } end |
#valid? ⇒ Boolean
51 52 53 |
# File 'tmpsets/set/mod002-core/all/actify.rb', line 51 def valid?(*) act { super } end |
#with_transaction_returning_status ⇒ Object
this is an override of standard rails behavior that rescues abort makes it so that :success abortions do not rollback
80 81 82 83 84 85 86 87 88 |
# File 'tmpsets/set/mod002-core/all/actify.rb', line 80 def with_transaction_returning_status status = nil self.class.transaction do add_to_transaction status = abortable { yield } raise ActiveRecord::Rollback unless status end status end |