Browse Source

Handle nil values when merging

master
Peter J. Jones 7 years ago
parent
commit
7a3e6fe8bb
1 changed files with 9 additions and 2 deletions
  1. 9
    2
      lib/pdf/fdf/field_loader.rb

+ 9
- 2
lib/pdf/fdf/field_loader.rb View File

@@ -28,8 +28,15 @@ class PDF::FDF::FieldLoader
##############################################################################
def find (new_field)
@fields.detect do |old_field|
(!new_field['name'].empty? && new_field['name'] == old_field.name) ||
(!new_field['alias'].empty? && new_field['alias'] == old_field.alias)
match?(old_field, new_field, 'name') ||
match?(old_field, new_field, 'alias')
end
end

##############################################################################
def match? (old_field, new_field, attr)
new_field[attr] &&
!new_field[attr].empty? &&
new_field[attr] == old_field.send(attr)
end
end

Loading…
Cancel
Save