lib/domain/api.rb in domain-1.0.0.rc1 vs lib/domain/api.rb in domain-1.0.0.rc2

- old
+ new

@@ -1,18 +1,8 @@ module Domain module API - # Returns the domain predicate, nil if no such predicate - # - # @return [Proc] - # the domain predicate (possibly nil) - # - # @api public - def predicate - nil - end - # Returns the super domain of `self`. # # @return [Class] # the super domain of `self` as a ruby class # @@ -41,8 +31,21 @@ # # @api public def super_domain_of?(dom) sub_domains.include?(dom) end + + # Raises a type error for `args`. + # + # @param [Array] args + # arguments passed to `new` or another factory method + # @raise TypeError + # + # @api protected + def domain_error!(first, *args) + first = [first]+args unless args.empty? + raise TypeError, "Can't convert `#{first.inspect}` into #{self}", caller + end + protected :domain_error! end # module API end # module Domain \ No newline at end of file