Module: Alf::Facade
- Included in:
- Alf
- Defined in:
- lib/alf/facade.rb
Instance Method Summary collapse
- #connect(*args, &bl) ⇒ Object
- #database(*args, &bl) ⇒ Object
- #examples(&bl) ⇒ Object
- #examples_adapter ⇒ Object
- #Heading(*args, &bl) ⇒ Object
- #query(*args, &bl) ⇒ Object
- #reader(source, *args) ⇒ Object
- #Relation(first, *rest, &bl) ⇒ Object
- #Tuple(first = nil, *rest, &bl) ⇒ Object
Instance Method Details
#connect(*args, &bl) ⇒ Object
8 9 10 |
# File 'lib/alf/facade.rb', line 8 def connect(*args, &bl) Alf::Database.connect(*args, &bl) end |
#database(*args, &bl) ⇒ Object
4 5 6 |
# File 'lib/alf/facade.rb', line 4 def database(*args, &bl) Alf::Database.new(*args, &bl) end |
#examples(&bl) ⇒ Object
22 23 24 |
# File 'lib/alf/facade.rb', line 22 def examples(&bl) Alf::Database.connect examples_adapter, &bl end |
#examples_adapter ⇒ Object
18 19 20 |
# File 'lib/alf/facade.rb', line 18 def examples_adapter Path.backfind('examples/suppliers_and_parts') end |
#Heading(*args, &bl) ⇒ Object
50 51 52 |
# File 'lib/alf/facade.rb', line 50 def Heading(*args, &bl) Alf::Heading.coerce(*args, &bl) end |
#query(*args, &bl) ⇒ Object
12 13 14 15 16 |
# File 'lib/alf/facade.rb', line 12 def query(*args, &bl) connect(*args) do |conn| conn.query(&bl) end end |
#reader(source, *args) ⇒ Object
26 27 28 |
# File 'lib/alf/facade.rb', line 26 def reader(source, *args) Alf::Reader.reader(source, *args) end |
#Relation(first, *rest, &bl) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/alf/facade.rb', line 30 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 |
#Tuple(first = nil, *rest, &bl) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/alf/facade.rb', line 38 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 |