Sha256: 2dd64797b87e9805dbd516da5436e50440133ed8a5039fc2800a2664c7f0020f
Contents?: true
Size: 1.48 KB
Versions: 17
Compression:
Stored size: 1.48 KB
Contents
require 'insxsync/insx_argument_error' # Provides a base class that provides all the methods required for custom error handling class ErrorHandlingIface # Wrapper method to raise an INSX_ArgumentError with proper parameters # @example Validate a parameter # failValidation if not (param == value) def failValidation(trace=caller(1)) raise InsxArgumentError.new(get_usage, self.class.name, trace) end # Provides the parent method for returning the usage of the calling method. # This method should be overridden in every subclass to setup a usage hash # using the method names as the keys and an array of strings as the values. # @example Example get_usage child method # def get_usage # if @usage.nil? # init_usage # @usage['new'] = [':paramA => String, :paramB=> String'] # end # # super # end def get_usage #if called from the initialize method, the user should see "new" sender = caller[2][/`([^']+)'/,1] == 'initialize' ? 'new' : caller[2][/`([^']+)'/,1] #search through each method in the hash and load it's usage(s) @usage.each_key do |method| if method == sender return @usage[method] end end @usage[nil] end # Initializes the usage hash for a instance such that any entries that do not exist # return '*** WARNING: Usage not defined ***' as the message def init_usage @usage = Hash.new(['*** WARNING: Usage not defined ***']) end end
Version data entries
17 entries across 17 versions & 1 rubygems