Sha256: 1097541b344d7dd1f083c738f39707132b82ddd3f5bd5127e2e4c735ef79037e

Contents?: true

Size: 753 Bytes

Versions: 3

Compression:

Stored size: 753 Bytes

Contents

module Alf
  class Relation
    module ClassMethods
      
      #
      # Coerces `val` to a relation.
      #
      # Recognized arguments are: Relation (identity coercion), Set of ruby hashes, 
      # Array of ruby hashes, Alf::Iterator.
      #
      # @return [Relation] a relation instance for the given set of tuples
      # @raise [ArgumentError] when `val` is not recognized
      #
      def coerce(val)
        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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
alf-0.12.2 lib/alf/relation/class_methods.rb
alf-0.12.1 lib/alf/relation/class_methods.rb
alf-0.12.0 lib/alf/relation/class_methods.rb