I have a source object where
class Source def ==(other) return false if self.url == nil || other == nil self.url == other.url end
and I have the following:
def self.merge_internal_and_external_sources(sources=[], external_sources=[]) (sources + external_sources).uniq end
I would like to combine the two lists and start pulling items from external_sources if they already exist in the list of sources. I'm not sure how to do it eloquently?
I also tried:
sources | external_sources
but does this give a result without removing duplicates because my == comparison wants to compare the 'url' attribute inside? For instance:
[src1] == [src2] # true list = [src1] | [src2] list.size # 2
source share