Sha256: a03a66cf02840412dd292e6fe45bab8d9ebed6927ddb1c99a376c929477442af

Contents?: true

Size: 555 Bytes

Versions: 7

Compression:

Stored size: 555 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)
          inject({}) do |all, e|
            all[e.send(key_attr)] = e unless all[e.send(key_attr)]
            all
          end
        end

      end
    end
  end
end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
percheron-0.6.4 lib/percheron/core_extensions.rb
percheron-0.6.3 lib/percheron/core_extensions.rb
percheron-0.6.2 lib/percheron/core_extensions.rb
percheron-0.6.1 lib/percheron/core_extensions.rb
percheron-0.6.0 lib/percheron/core_extensions.rb
percheron-0.5.0 lib/percheron/core_extensions.rb
percheron-0.4.0 lib/percheron/core_extensions.rb