Class: Erector::Dependencies

Inherits:
Array
  • Object
show all
Defined in:
lib/erector/dependencies.rb

Instance Method Summary collapse

Instance Method Details

#push(*new_dependencies_args) ⇒ Object Also known as: <<



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/erector/dependencies.rb', line 3

def push(*new_dependencies_args)
  new_dependencies = new_dependencies_args.select do |new_dependency|
    !include?(new_dependency)
  end
  new_dependencies.each do |dep|
    unless dep.is_a? Erector::Dependency
      raise "expected Dependency, got #{dep.class}: #{dep.inspect}"
    end
  end
  super(*new_dependencies)
end

#uniqObject



17
18
19
20
21
22
# File 'lib/erector/dependencies.rb', line 17

def uniq
  inject(self.class.new) do |memo, item|
    memo << item unless memo.any? {|memo_item| memo_item == item}
    memo
  end
end