Class: Bmg::Sequel::Relation
Instance Attribute Summary collapse
#type
Instance Method Summary
collapse
#bind
Methods included from Relation
#bind, #debug, empty, #empty?, new, #one, #one_or_nil, #to_json, #visit, #with_typecheck, #without_typecheck, #y_by_x, #ys_by_x
Methods included from Algebra
#allbut, #autosummarize, #autowrap, #constants, #extend, #group, #image, #join, #matching, #materialize, #not_matching, #page, #project, #rename, #restrict, #spied, #summarize, #union, #unspied
#image, #join, #matching, #not_matching, #prefix, #rxmatch, #suffix
Constructor Details
#initialize(type, builder, source, sequel_db) ⇒ Relation
Returns a new instance of Relation.
5
6
7
8
|
# File 'lib/bmg/sequel/relation.rb', line 5
def initialize(type, builder, source, sequel_db)
super(type, builder, source)
@sequel_db = sequel_db
end
|
Instance Attribute Details
#sequel_db ⇒ Object
Returns the value of attribute sequel_db.
9
10
11
|
# File 'lib/bmg/sequel/relation.rb', line 9
def sequel_db
@sequel_db
end
|
Instance Method Details
#delete ⇒ Object
15
16
17
|
# File 'lib/bmg/sequel/relation.rb', line 15
def delete
base_table.delete
end
|
#each(&bl) ⇒ Object
11
12
13
|
# File 'lib/bmg/sequel/relation.rb', line 11
def each(&bl)
dataset.each(&bl)
end
|
#insert(arg) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/bmg/sequel/relation.rb', line 19
def insert(arg)
case arg
when Hash then
base_table.insert(arg.merge(type.predicate.constants))
when Enumerable then
base_table.multi_insert(arg.map { |x|
x.merge(type.predicate.constants)
})
else
base_table.insert(arg.merge(type.predicate.constants))
end
end
|
#to_ast ⇒ Object
36
37
38
|
# File 'lib/bmg/sequel/relation.rb', line 36
def to_ast
[:sequel, dataset.sql]
end
|
#to_s ⇒ Object
Also known as:
inspect
44
45
46
|
# File 'lib/bmg/sequel/relation.rb', line 44
def to_s
"(sequel #{dataset.sql})"
end
|
#to_sql ⇒ Object
40
41
42
|
# File 'lib/bmg/sequel/relation.rb', line 40
def to_sql
dataset.sql
end
|
#update(arg) ⇒ Object
32
33
34
|
# File 'lib/bmg/sequel/relation.rb', line 32
def update(arg)
base_table.update(arg)
end
|