Module: Sequel::Plugins::ProcErrorHandling::InstanceMethods
- Defined in:
- lib/sequel_proc_error_handling.rb
Instance Method Summary collapse
- #initialize(values = {}, *args, &block) ⇒ Object
- #save(*columns) ⇒ Object
- #update(hash, *error_proc) ⇒ Object
- #update_all(hash, *error_proc) ⇒ Object
- #update_except(hash, *except) ⇒ Object
- #update_only(hash, *only) ⇒ Object
Instance Method Details
#initialize(values = {}, *args, &block) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/sequel_proc_error_handling.rb', line 72 def initialize(values = {}, *args,&block) orig = args.dup error_procs = [] error_procs.unshift args.pop while args.last.is_a? Proc from_db = args.pop || false # First value will be nil or boolean raise ArgumentError, "Invalid Arguments passed to #new #{orig.inpsect}" unless args.empty? begin super(values,from_db,&block) rescue result = PEH.send(:process_error_proc,error_procs,self,values) retry if result == :retry # Special for new since we can't return anything else if result.is_a? self.class values = result.values from_db = true unless result.new? retry end # Should not get here... means result was something other # then :raise, :retry, nil, or an instance of self.class raise "#new can not return any other object, there is" << " an error in your PEH proc" end end |
#save(*columns) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/sequel_proc_error_handling.rb', line 98 def save(*columns) error_procs = [] error_procs.unshift columns.pop while columns.last.is_a? Proc begin super(*columns) rescue result = PEH.send(:process_error_proc,error_procs,self,values) retry if result == :retry result end end |
#update(hash, *error_proc) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/sequel_proc_error_handling.rb', line 29 def update(hash,*error_proc) super(hash) rescue result = PEH.send(:process_error_proc,error_proc,self,hash) retry if result == :retry result end |
#update_all(hash, *error_proc) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/sequel_proc_error_handling.rb', line 37 def update_all(hash, *error_proc) super(hash) rescue result = PEH.send(:process_error_proc,error_proc,self,hash) retry if result == :retry result end |
#update_except(hash, *except) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sequel_proc_error_handling.rb', line 45 def update_except(hash, *except) error_procs = [] error_procs.unshift except.pop while except.last.is_a? Proc # Only want to retry the update, don't want to clear error_procs begin super(hash,*except) rescue result = PEH.send(:process_error_proc,error_procs,self,hash) retry if result == :retry result end end |
#update_only(hash, *only) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/sequel_proc_error_handling.rb', line 59 def update_only(hash, *only) error_procs = [] error_procs.unshift only.pop while only.last.is_a? Proc begin super(hash,*only) rescue result = PEH.send(:process_error_proc,error_procs,self,hash) retry if result == :retry result end end |