class DynarexRecordset

Public Class Methods

new(a, caller=nil) click to toggle source
Calls superclass method
# File lib/dynarex.rb, line 43
def initialize(a, caller=nil)
  super(a)
  @caller = caller
end

Public Instance Methods

index(val) click to toggle source
# File lib/dynarex.rb, line 63
def index(val)    
  self.map(&:to_h).index val.to_h
end
index_by_id(id) click to toggle source
# File lib/dynarex.rb, line 67
def index_by_id(id)    
  self.map(&:id).index id
end
reject!() click to toggle source
Calls superclass method
# File lib/dynarex.rb, line 48
def reject!()
  
  a = self.to_a.clone
  a2 = super
  return nil unless a2
  a3 = a - a2
 
  @caller.delete  a3.map(&:id)
  self
end
sum(field) click to toggle source
# File lib/dynarex.rb, line 59
def sum(field)
  self.inject(0) {|r, x| r + x[field.to_sym][/\d+(\.\d+)?$/].to_f }
end