Sha256: 8f664908fa7bf4f54522d91510353687a3f85673336fd50fc313495a802863e8

Contents?: true

Size: 379 Bytes

Versions: 10

Compression:

Stored size: 379 Bytes

Contents

class Class

  # Convert instatiation of a class into a Proc.
  #
  #   class Person
  #     def initialize(name)
  #       @name = name
  #     end
  #
  #     def inspect
  #       @name.to_str
  #     end
  #   end
  #
  #   %w(john bob jane hans).map(&Person) => [john, bob, jane, hans]
  #
  # CREDIT: Daniel Schierbeck
  def to_proc
    proc{|*args| new(*args)}
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/class/to_proc.rb
facets-2.8.3 lib/core/facets/class/to_proc.rb
facets-2.8.2 lib/core/facets/class/to_proc.rb
facets-2.8.1 lib/core/facets/class/to_proc.rb
facets-2.8.0 lib/core/facets/class/to_proc.rb
facets-2.7.0 lib/core/facets/class/to_proc.rb
facets-2.6.0 lib/core/facets/class/to_proc.rb
facets-2.5.1 lib/core/facets/class/to_proc.rb
facets-2.5.0 lib/core/facets/class/to_proc.rb
facets-2.5.2 lib/core/facets/class/to_proc.rb