Sha256: d5d57f5ef817b3cb55411dcaaa39f6a7bab615b3e983e2c0408695ea79188bd6

Contents?: true

Size: 307 Bytes

Versions: 160

Compression:

Stored size: 307 Bytes

Contents

class Object
  # Tries the given methods and returns the first one to return a value,
  # ultimately returns nil if no value is found.
  def try(*methods)
    methods.each do |method|
      if self.respond_to?(method)
        val = send(method)
        return val if val
      end
    end
    nil
  end
end

Version data entries

160 entries across 160 versions & 1 rubygems

Version Path
origen-0.53.0 lib/origen/core_ext/object.rb
origen-0.52.4 lib/origen/core_ext/object.rb
origen-0.52.3 lib/origen/core_ext/object.rb
origen-0.52.2 lib/origen/core_ext/object.rb
origen-0.52.1 lib/origen/core_ext/object.rb
origen-0.52.0 lib/origen/core_ext/object.rb
origen-0.51.3 lib/origen/core_ext/object.rb
origen-0.51.2 lib/origen/core_ext/object.rb
origen-0.51.1 lib/origen/core_ext/object.rb
origen-0.51.0 lib/origen/core_ext/object.rb
origen-0.50.0 lib/origen/core_ext/object.rb
origen-0.44.0 lib/origen/core_ext/object.rb
origen-0.43.0 lib/origen/core_ext/object.rb
origen-0.42.2 lib/origen/core_ext/object.rb
origen-0.42.1 lib/origen/core_ext/object.rb
origen-0.42.0 lib/origen/core_ext/object.rb
origen-0.41.2 lib/origen/core_ext/object.rb
origen-0.41.1 lib/origen/core_ext/object.rb
origen-0.41.0 lib/origen/core_ext/object.rb
origen-0.40.2 lib/origen/core_ext/object.rb