Sha256: 3de54ba4d0aa7f9277e07be1cda6fae5212abaab02cc35d6dd4b87bec4493e85
Contents?: true
Size: 1.13 KB
Versions: 5
Compression:
Stored size: 1.13 KB
Contents
module Bmg module Relation class Spied include Operator::Unary def initialize(operand, spy) @operand = operand @spy = spy end protected attr_reader :spy public def type operand.type end def each(&bl) spy.call(self) operand.each(&bl) end def to_ast [ :spied, operand.to_ast, spy ] end public ### algebra Algebra.public_instance_methods(false).each do |m| next if [:spied, :unspied].include?(m) define_method(m) do |*args, &bl| args = args.map{|a| a.respond_to?(:unspied) ? a.unspied : a } operand.send(m, *args, &bl).spied(spy) end end def unspied operand end public ### update def insert(*args, &bl) operand.insert(*args, &bl) end def delete(*args, &bl) operand.delete(*args, &bl) end def update(*args, &bl) operand.update(*args, &bl) end protected ### inspect def args [ spy ] end end # class Spied end # module Relation end # module Bmg
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
bmg-0.13.0 | lib/bmg/relation/spied.rb |
bmg-0.12.0 | lib/bmg/relation/spied.rb |
bmg-0.11.0 | lib/bmg/relation/spied.rb |
bmg-0.10.1 | lib/bmg/relation/spied.rb |
bmg-0.10.0 | lib/bmg/relation/spied.rb |