Class: Bmg::Relation::InMemory::Mutable

Inherits:
InMemory
  • Object
show all
Defined in:
lib/bmg/relation/in_memory/mutable.rb

Instance Method Summary collapse

Instance Method Details

#delete(predicate = Predicate.tautology) ⇒ Object



17
18
19
# File 'lib/bmg/relation/in_memory/mutable.rb', line 17

def delete(predicate = Predicate.tautology)
  @operand = @operand.select{|t| predicate.call(t) }
end

#insert(arg) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
# File 'lib/bmg/relation/in_memory/mutable.rb', line 5

def insert(arg)
  raise ArgumentError unless arg.is_a?(Hash)

  @operand << arg.dup
end

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



11
12
13
14
15
# File 'lib/bmg/relation/in_memory/mutable.rb', line 11

def update(updating, predicate = Predicate.tautology)
  @operand = @operand.map{|t|
    predicate.call(t) ? t.merge(updating) : t
  }
end