Sha256: 5b868b6bf9cfc18a7fd13b8153d606af5d963066dfc9567ebcc36fe073ee2892
Contents?: true
Size: 885 Bytes
Versions: 9
Compression:
Stored size: 885 Bytes
Contents
class Object # Setup a default pretty_inspect # alias_method :pretty_inspect, :inspect def instance_values Hash[instance_variables.map { |name| [name[1..-1], instance_variable_get(name)] }] end # Provides the same functionality as ||, but treats a nil model as falsy def or(other) if self && !self.nil? return self else return other end end # Provides the same functionality as &&, treats a nil model as falsy def and(other) if self && !self.nil? return other else return self end end def html_inspect inspect.gsub('<', '<').gsub('>', '>') end # TODO: Need a real implementation of this def deep_clone Marshal.load(Marshal.dump(self)) end def try(*a, &b) if a.empty? && block_given? yield self else public_send(*a, &b) if respond_to?(a.first) end end end
Version data entries
9 entries across 9 versions & 1 rubygems