Class: Bmg::Redis::Singleton

Inherits:
Object
  • Object
show all
Includes:
Bmg::Relation
Defined in:
lib/bmg/redis/singleton.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, parent, tuple) ⇒ Singleton

Returns a new instance of Singleton.



6
7
8
9
10
# File 'lib/bmg/redis/singleton.rb', line 6

def initialize(type, parent, tuple)
  @type = type
  @parent = parent
  @tuple = tuple
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



11
12
13
# File 'lib/bmg/redis/singleton.rb', line 11

def type
  @type
end

Instance Method Details

#delete(predicate = Predicate.tautology) ⇒ Object



29
30
31
# File 'lib/bmg/redis/singleton.rb', line 29

def delete(predicate = Predicate.tautology)
  @parent.delete(predicate & type.predicate)
end

#each {|@tuple| ... } ⇒ Object

Yields:

  • (@tuple)


13
14
15
16
17
# File 'lib/bmg/redis/singleton.rb', line 13

def each
  return to_enum unless block_given?

  yield(@tuple) if @tuple
end

#insert(tuple_or_tuples) ⇒ Object



19
20
21
22
# File 'lib/bmg/redis/singleton.rb', line 19

def insert(tuple_or_tuples)
  @parent.insert(tuple_or_tuples)
  self
end

#update(updating, predicate = Predicate.tautology) ⇒ Object



24
25
26
27
# File 'lib/bmg/redis/singleton.rb', line 24

def update(updating, predicate = Predicate.tautology)
  @parent.update(updating, predicate & type.predicate)
  self
end