Sha256: b0995d9b667e80f13ddece51379219499d6dc30641ff1c3a49d06d1dc2057104

Contents?: true

Size: 480 Bytes

Versions: 31

Compression:

Stored size: 480 Bytes

Contents

##
# Meta-programming Proc for Syntactic Sugars
class Proc
  # Convert [Proc] to [Lambda]
  # @param [Object] instance the context
  # @return [Lambda] Lambda converted
  # @note Converting [Proc] to [Lambda] may have incorrect behaviours on corner cases.
  # @note See {Ruby Language Issues}[https://bugs.ruby-lang.org/issues/7314] for more details.
  def to_lambda(instance = Object.new)
    instance.define_singleton_method(:_, &self)
    instance.method(:_).to_proc
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
midori.rb-0.9.0 lib/midori/core_ext/proc.rb
midori.rb-0.8.0 lib/midori/core_ext/proc.rb
midori.rb-0.7.1 lib/midori/core_ext/proc.rb
midori.rb-0.7.0 lib/midori/core_ext/proc.rb
midori.rb-0.6.0 lib/midori/core_ext/proc.rb
midori.rb-0.5.4 lib/midori/core_ext/proc.rb
midori.rb-0.5.3.1 lib/midori/core_ext/proc.rb
midori.rb-0.5.3 lib/midori/core_ext/proc.rb
midori.rb-0.5.2 lib/midori/core_ext/proc.rb
midori.rb-0.5.1 lib/midori/core_ext/proc.rb
midori.rb-0.5.0 lib/midori/core_ext/proc.rb
midori.rb-0.4.4.1 lib/midori/core_ext/proc.rb
midori.rb-0.4.4 lib/midori/core_ext/proc.rb
midori.rb-0.4.3 lib/midori/core_ext/proc.rb
em-midori-0.4.3 lib/midori/core_ext/proc.rb
em-midori-0.4.2.1 lib/midori/core_ext/proc.rb
em-midori-0.4.2 lib/midori/core_ext/proc.rb
em-midori-0.4.1.1 lib/midori/core_ext/proc.rb
em-midori-0.4.1 lib/midori/core_ext/proc.rb
em-midori-0.4.0 lib/midori/core_ext/proc.rb