[open-ils-commits] r236 - acq_edi/trunk/lib/openils (mbklein)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Mar 31 19:02:40 EDT 2009
Author: mbklein
Date: 2009-03-31 19:02:40 -0400 (Tue, 31 Mar 2009)
New Revision: 236
Modified:
acq_edi/trunk/lib/openils/mapper.rb
Log:
Removed active_support dependency
Modified: acq_edi/trunk/lib/openils/mapper.rb
===================================================================
--- acq_edi/trunk/lib/openils/mapper.rb 2009-03-31 22:56:08 UTC (rev 235)
+++ acq_edi/trunk/lib/openils/mapper.rb 2009-03-31 23:02:40 UTC (rev 236)
@@ -1,4 +1,3 @@
-require 'active_support'
require 'edi/mapper'
module OpenILS
@@ -39,7 +38,17 @@
OpenILS::Mapper.map 'item' do |mapper,key,value|
mapper.add('LIN', { 'C212' => { '7143' => nil }, '1082' => value['line_index'] })
- id_groups = value['identifiers'].in_groups_of(5)
+
+ # use Array#inject() to group the identifiers in groups of 5.
+ # Same as Array#in_groups_of() without the active_support dependency.
+ id_groups = value['identifiers'].inject([[]]) { |result,id|
+ result.last << id
+ if result.last.length == 5
+ result << []
+ end
+ result
+ }
+
id_groups.each { |group|
ids = group.compact.collect { |data|
id = { '7140' => data['id'] }
More information about the open-ils-commits
mailing list