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

Inherits:
Bmg::Relation::InMemory show all
Defined in:
lib/bmg/relation/in_memory/mutable.rb

Instance Attribute Summary

Attributes inherited from Bmg::Relation::InMemory

#operand, #type

Instance Method Summary collapse

Methods inherited from Bmg::Relation::InMemory

#_count, #each, #initialize, #inspect, #to_ast, #to_s

Methods included from Bmg::Relation

#_count, #bind, #count, #debug, empty, #empty?, new, #one, #one_or_nil, #to_ast, #to_csv, #to_json, #to_xlsx, #type, #visit, #with_type, #with_type_attrlist, #with_typecheck, #without_typecheck, #y_by_x, #ys_by_x

Methods included from Algebra

#allbut, #autosummarize, #autowrap, #constants, #extend, #group, #image, #join, #left_join, #matching, #materialize, #not_matching, #page, #project, #rename, #restrict, #spied, #summarize, #transform, #ungroup, #union, #unspied, #unwrap

Methods included from Algebra::Shortcuts

#exclude, #image, #images, #join, #left_join, #matching, #not_matching, #prefix, #rxmatch, #suffix, #ungroup, #unwrap, #where

Constructor Details

This class inherits a constructor from Bmg::Relation::InMemory

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