Sha256: 65b7f21cdf03f3b403097777d525231b86339c228ff2f8e84dfe859387710ce7
Contents?: true
Size: 646 Bytes
Versions: 1
Compression:
Stored size: 646 Bytes
Contents
class Object # Chained try # # Allows writing # # str.ctry(:mb_chars, :downcase, :dasherize) # # instead of # # str.try(:mb_chars).try(:downcase).try(:dasherize) # # Only works for methods that dont have any arguments def ctry(*args) first, *rest = args if rest.any? self.try(first).ctry(*rest) else self.try(first) end end # Returns self. If given a block, it works a lot like Object#tap # # ==== Examples # # [1,2,3,5,7].consecutive_by(:identity) # => [[1, 2, 3], [5], [7]] def identity if block_given? yield self else self end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
inactive_support-0.0.1 | lib/inactive_support/core_ext/object.rb |