Sha256: 05660bf7eeb806f01aca8be4af60731ff35664bcef0835280e15f552ec260eb3
Contents?: true
Size: 617 Bytes
Versions: 1
Compression:
Stored size: 617 Bytes
Contents
## # Argument Validation 是参数验证逻辑的关注点。 module Unidom::Common::Concerns::ArgumentValidation extend ActiveSupport::Concern included do |includer| ## # 断言给定的参数 value 非空。如果为空,则抛出 ArgumentError 异常。如: # assert_present! :person, person def assert_present!(name, value) raise ArgumentError.new("The #{name} argument is required.") if value.blank? end end module ClassMethods def assert_present!(name, value) raise ArgumentError.new("The #{name} argument is required.") if value.blank? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unidom-common-1.10 | app/models/unidom/common/concerns/argument_validation.rb |