Sha256: 9d5199096959c8cf3665c523a518188d9849e9c152c62a5fd4221df79bb4ad0a

Contents?: true

Size: 547 Bytes

Versions: 4

Compression:

Stored size: 547 Bytes

Contents

module Percheron
  module CoreExtensions
    module Array
      module Extras
        def return
          result = nil
          each do |x|
            r = yield(x)
            if r
              result = r
              break
            end
          end
          result
        end

        def to_hash_by_key(key_attr)
          each_with_object({}) do |e, all|
            all[e.send(key_attr)] = e unless all[e.send(key_attr)]
          end
        end
      end
    end
  end
end

Array.include(Percheron::CoreExtensions::Array::Extras)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
percheron-0.7.3 lib/percheron/core_extensions.rb
percheron-0.7.2 lib/percheron/core_extensions.rb
percheron-0.7.1 lib/percheron/core_extensions.rb
percheron-0.7.0 lib/percheron/core_extensions.rb