Sha256: 4949d0bf502cf2c2ee13bf3c7b6bb5543f3d053d1abaaaaa85815d9c68f0e751

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module Alf
  module Facade

    def database(*args, &bl)
      Alf::Database.new(*args, &bl)
    end

    def connect(*args, &bl)
      Alf::Database.connect(*args, &bl)
    end

    def query(*args, &bl)
      connect(*args) do |conn|
        conn.query(&bl)
      end
    end

    def examples_adapter
      Path.backfind('examples/suppliers_and_parts')
    end

    def examples(&bl)
      Alf::Database.connect examples_adapter, &bl
    end

    def reader(source, *args)
      Alf::Reader.reader(source, *args)
    end

    def Relation(first, *rest, &bl)
      if first.respond_to?(:to_relation) && rest.empty? && bl.nil?
        return first.to_relation
      else
        Alf::Relation.coerce(*rest.unshift(first), &bl)
      end
    end

    def Tuple(first = nil, *rest, &bl)
      if first.nil? or (first.is_a?(Hash) && first.empty?)
        Alf::Tuple::EMPTY
      elsif first.respond_to?(:to_tuple) && rest.empty? && bl.nil?
        return first.to_tuple
      else
        tuple = Alf::Tuple.coerce(*rest.unshift(first))
        tuple = tuple.remap(&bl) if bl
        tuple
      end
    end

    def Heading(*args, &bl)
      Alf::Heading.coerce(*args, &bl)
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/facade.rb
alf-core-0.16.2 lib/alf/facade.rb
alf-core-0.16.1 lib/alf/facade.rb
alf-core-0.16.0 lib/alf/facade.rb