Sha256: fd8f79b8f9647edab4201d3dcc8b8a7bd5da770560d32b52ad7ac0a64f3dac41
Contents?: true
Size: 938 Bytes
Versions: 4
Compression:
Stored size: 938 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? self else other end end # Provides the same functionality as &&, treats a nil model as falsy def and(other) if self && !self.nil? other else self end end def html_inspect inspect.gsub('<', '<').gsub('>', '>') end # TODO: Need a real implementation of this def deep_clone if RUBY_PLATFORM == 'opal' JSON.parse(self.to_json) else Marshal.load(Marshal.dump(self)) end 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
4 entries across 4 versions & 1 rubygems