Class: Bmg::Sequel::Relation

Inherits:
Object
  • Object
show all
Includes:
Relation
Defined in:
lib/bmg/sequel/relation.rb

Constant Summary

Constants included from Algebra

Algebra::METHODS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Relation

#debug, empty, #empty?, new, #one, #one_or_nil, #to_json, #visit, #ys_by_x

Methods included from Algebra

#allbut, #autosummarize, #autowrap, #constants, #extend, #image, #project, #rename, #restrict, #spied, #union, #unspied

Constructor Details

#initialize(type, dataset) ⇒ Relation

Returns a new instance of Relation.



6
7
8
9
# File 'lib/bmg/sequel/relation.rb', line 6

def initialize(type, dataset)
  @type = type
  @dataset = dataset
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



10
11
12
# File 'lib/bmg/sequel/relation.rb', line 10

def type
  @type
end

Instance Method Details

#deleteObject



22
23
24
# File 'lib/bmg/sequel/relation.rb', line 22

def delete
  dataset.delete
end

#each(&bl) ⇒ Object



18
19
20
# File 'lib/bmg/sequel/relation.rb', line 18

def each(&bl)
  @dataset.each(&bl)
end

#insert(arg) ⇒ Object



26
27
28
# File 'lib/bmg/sequel/relation.rb', line 26

def insert(arg)
  dataset.insert(arg.merge(type.predicate.constants))
end

#to_astObject



34
35
36
# File 'lib/bmg/sequel/relation.rb', line 34

def to_ast
  [:sequel, dataset.sql]
end

#to_sObject Also known as: inspect



38
39
40
# File 'lib/bmg/sequel/relation.rb', line 38

def to_s
  "(sequel #{dataset.sql})"
end

#update(arg) ⇒ Object



30
31
32
# File 'lib/bmg/sequel/relation.rb', line 30

def update(arg)
  dataset.update(arg)
end