module NCipher::ArgumentValidation::ClassMethod

Private Instance Methods

args_validation(method, message=nil, &validation) click to toggle source
# File lib/n_cipher/argument_validation.rb, line 29
def args_validation(method, message=nil, &validation)
  exception = ArgumentError.new(message).tap do |ex|
    # バックトレースの偽装
    ex.set_backtrace(validation.source_location.push("in `args_validation'").join(':'))
  end

  ::NCipher::ArgumentValidation.store_validation(self, "__#{method}__", validation, exception)

  unless private_method_defined?("__#{method}__")
    ::NCipher::ArgumentValidation.around_alias(self, "__#{method}__", method)
    ::NCipher::ArgumentValidation.define_proxy_method(self, method)
  end

  self
end