lib/eco/data/mapper.rb in eco-helpers-0.6.6 vs lib/eco/data/mapper.rb in eco-helpers-0.6.7
- old
+ new
@@ -5,10 +5,11 @@
# it expects [[v1a, v1b], [v2a, v2b] ...]
def initialize (array_of_arrays = [], internal: :last)
@source = array_of_arrays
if @source
+ # internal should be always last in @source
@source = @source.map { |a| a.reverse } unless internal == :last
# first declarations take priority
@by_external = @source.reverse.to_h
@by_internal = @source.reverse.map do |pair|
@@ -18,10 +19,10 @@
end
def list(type = :internal)
return [] if !@source
@source.map do |pair|
- type == :internal ? pair.first : pair.last
+ type == :internal ? pair.last : pair.first
end.uniq
end
def internal?(value)
return true if !@source