Sha256: f9ef41cd75c21a5b2cecbd53cefebd6c242a7efe6e9769c2f982ffb605cbc1d4

Contents?: true

Size: 377 Bytes

Versions: 1

Compression:

Stored size: 377 Bytes

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exec_if-0.3.0 lib/exec_if.rb