def search_by_attribute(things, options = {}, limit = 1000)
      things.find_all do |thing|
        options.inject(true) do |memo, kv|
          break unless memo
          key, value = kv
          begin
            memo &= thing.send(key) == value
          rescue NoMethodError
            memo = false
          end
          memo
        end and (limit -= 1) > 0
      end
    end
def search_by_attribute(things, options = {}, limit = 1000)
      things.find_all do |thing|
        options.inject(true) do |memo, kv|
          break unless memo
          key, value = kv
          begin
            memo &= thing.send(key) == value
          rescue NoMethodError
            memo = false
          end
          memo
        end and (limit -= 1) > 0
      end
    end
def search_by_attribute ( things , options = { } , limit = 1000 ) things . find_all do | thing | options . inject ( true ) do | memo , kv | break unless memo key , value = kv begin memo &= thing . send ( key ) == value rescue NoMethodError memo = false end memo end and ( limit -= 1 ) > 0 end end
Goes through all the things and returns results that match the options attributes hash
Goes through all the things and returns results that match the options attributes hash