Sha256: 6d8c44b8dad5a703cc2a79a5b3de3f913cbb9bc3cec06f737c45a8a93b0f4f50
Contents?: true
Size: 664 Bytes
Versions: 18
Compression:
Stored size: 664 Bytes
Contents
module ObjectAttorney module Helpers extend self def is_integer?(string) string.match(/^(\d)+$/) end def singularize(class_name) class_name = class_name.to_s plural?(class_name) ? class_name.singularize : class_name end def plural?(string) string = string.to_s string == string.pluralize end def try_or_return(object, method, default_value) returning_value = object.try(method) returning_value.nil? ? default_value : returning_value end def has_errors_method?(object) object.present? && object.respond_to?(:errors) && !object.errors.nil? end end end
Version data entries
18 entries across 18 versions & 1 rubygems