lib/alf/relation/class_methods.rb in alf-0.11.1 vs lib/alf/relation/class_methods.rb in alf-0.12.0
- old
+ new
@@ -10,28 +10,19 @@
#
# @return [Relation] a relation instance for the given set of tuples
# @raise [ArgumentError] when `val` is not recognized
#
def coerce(val)
- case val
- when Relation
- val
- when Set
- Relation.new(val)
- when Array
- Relation.new val.to_set
- when Iterator
- Relation.new val.to_set
- else
- raise ArgumentError, "Unable to coerce #{val} to a Relation"
- end
+ Alf::Tools.to_relation(val)
+ rescue Myrrha::Error
+ raise ArgumentError, "Unable to coerce `#{val}` to a Relation"
end
# (see Relation.coerce)
def [](*tuples)
coerce(tuples)
end
end # module ClassMethods
extend(ClassMethods)
end # class Relation
-end # module Alf
\ No newline at end of file
+end # module Alf