lib/language_cards/comparator.rb in language_cards-0.0.1 vs lib/language_cards/comparator.rb in language_cards-0.0.2

- old
+ new

@@ -4,10 +4,16 @@ class Comparator def initialize mapping_key, mapping, collection ## # @title should be a hash like {"Romaji"=>"Katakana"} # @mapping should be an array like [:k, :v] - @mapped_as, @mapping = mapping[mapping_key].reduce + raise I18n.t('Error.MappingNotFound') unless mapping.has_key? mapping_key + begin + @mapped_as, @mapping = mapping[mapping_key].reduce + rescue LocalJumpError + raise I18n.t('Errors.InvalidMapping') + end + @collection = collection end def mapped_as case @mapping.first