Sha256: 6a83940e3f1642faca5c663035d649aa14671aa68a23f67baabba9dbcb77d9fe

Contents?: true

Size: 394 Bytes

Versions: 2

Compression:

Stored size: 394 Bytes

Contents

# encoding: UTF-8

class Array
  def where(options={})
    result = []
    self.each do |item|
      if item.respond_to?(:name) && item.name == options[:name]
        result << item
      end

      if item.respond_to?(:id) && item.id == options[:id]
        result << item
      end
    end

    result.uniq!

    if result.size == 1
      result.first
    else
      result
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cucumber_monitor-0.0.2 lib/cucumber_monitor/array.rb
cucumber_monitor-0.0.1 lib/cucumber_monitor/array.rb