Sha256: 6b542e52eed426cd58944a87bbacb74b75861c09948290b2d7f5d9b1137e73bb

Contents?: true

Size: 375 Bytes

Versions: 1

Compression:

Stored size: 375 Bytes

Contents

require "exec_if/version"

class Object
  def exec_if(obj, &blk)
    case obj
    when Proc
      obj.call(self) ? blk.call(self, obj) : self
    when Symbol
      public_send(obj) ? blk.call(self, obj) : self
    when String
      eval(obj) ? blk.call(self, obj) : self
    when Object
      obj ? blk.call(self, obj) : self
    when nil, false
      self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exec_if-0.2.0 lib/exec_if.rb