class GoodServices::Base
Constants
- DEFAULT_RESCUES
Attributes
default_rescues[RW]
rescuable_list[RW]
collection[R]
error[R]
record[R]
Public Class Methods
acceptable_exceptions()
click to toggle source
This method returns either the set rescuable_from
or the defaults
# File lib/good_services/base.rb, line 72 def self.acceptable_exceptions (@rescuable_list + @default_rescues).uniq end
inherit_variables(rescuable_list, default_rescues)
click to toggle source
# File lib/good_services/base.rb, line 13 def inherit_variables(rescuable_list, default_rescues) @rescuable_list = rescuable_list || [] @default_rescues = default_rescues || DEFAULT_RESCUES end
inherited(subclass)
click to toggle source
# File lib/good_services/base.rb, line 18 def inherited(subclass) subclass.inherit_variables(@rescuable_list, @default_rescues) end
rescuable_from(*rescuable_exceptions)
click to toggle source
This configuration method adds custom exceptions to the rescuable list
# File lib/good_services/base.rb, line 65 def self.rescuable_from(*rescuable_exceptions) @rescuable_list = rescuable_exceptions end
run(*args)
click to toggle source
Helpers for instancing and running the Service
# File lib/good_services/base.rb, line 26 def self.run(*args) self.new(*args).run end
run!(*args)
click to toggle source
# File lib/good_services/base.rb, line 30 def self.run!(*args) self.new(*args).run! end
Public Instance Methods
perform()
click to toggle source
# File lib/good_services/base.rb, line 59 def perform end
run()
click to toggle source
Runs the validations and perform methods rescuing from known exceptions Returns either true or false
# File lib/good_services/base.rb, line 48 def run validate perform return true rescue *self.class.acceptable_exceptions => @error return false end
run!()
click to toggle source
Runs the validations and perform methods Returns true or raise an exception
# File lib/good_services/base.rb, line 38 def run! validate perform return true end
validate()
click to toggle source
# File lib/good_services/base.rb, line 56 def validate end