Sha256: 7a2e37d17b0385df627f507091f766c9a7a8cbbc6cc16fa35f13b92c9e4b1bea

Contents?: true

Size: 554 Bytes

Versions: 15

Compression:

Stored size: 554 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.send(:include, Percheron::CoreExtensions::Array::Extras)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
percheron-0.8.1 lib/percheron/core_extensions.rb
percheron-0.8.0 lib/percheron/core_extensions.rb
percheron-0.7.16 lib/percheron/core_extensions.rb
percheron-0.7.15 lib/percheron/core_extensions.rb
percheron-0.7.14 lib/percheron/core_extensions.rb
percheron-0.7.13 lib/percheron/core_extensions.rb
percheron-0.7.12 lib/percheron/core_extensions.rb
percheron-0.7.11 lib/percheron/core_extensions.rb
percheron-0.7.10 lib/percheron/core_extensions.rb
percheron-0.7.9 lib/percheron/core_extensions.rb
percheron-0.7.8 lib/percheron/core_extensions.rb
percheron-0.7.7 lib/percheron/core_extensions.rb
percheron-0.7.6 lib/percheron/core_extensions.rb
percheron-0.7.5 lib/percheron/core_extensions.rb
percheron-0.7.4 lib/percheron/core_extensions.rb