From 6d21fc330cccba65c1b675496213cead03ef2321 Mon Sep 17 00:00:00 2001 From: mbklein Date: Tue, 31 Mar 2009 23:02:40 +0000 Subject: [PATCH] Removed active_support dependency git-svn-id: svn://svn.open-ils.org/ILS-Contrib/acq_edi/trunk@236 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- lib/openils/mapper.rb | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/openils/mapper.rb b/lib/openils/mapper.rb index 24506249c..76cbfc517 100644 --- a/lib/openils/mapper.rb +++ b/lib/openils/mapper.rb @@ -1,4 +1,3 @@ -require 'active_support' require 'edi/mapper' module OpenILS @@ -39,7 +38,17 @@ end 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'] } -- 2.11.0