Sha256: fb2af4a81881d0dbd3d328ea07d3f14dd87c038817e949b386a9c5dfe6b8aaf5

Contents?: true

Size: 744 Bytes

Versions: 13

Compression:

Stored size: 744 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('<', '&lt;').gsub('>', '&gt;')
  end

  # TODO: Need a real implementation of this
  def deep_clone
    Marshal.load(Marshal.dump(self))
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
volt-0.8.21 lib/volt/extra_core/object.rb
volt-0.8.20 lib/volt/extra_core/object.rb
volt-0.8.19 lib/volt/extra_core/object.rb
volt-0.8.18 lib/volt/extra_core/object.rb
volt-0.8.17 lib/volt/extra_core/object.rb
volt-0.8.16 lib/volt/extra_core/object.rb
volt-0.8.15 lib/volt/extra_core/object.rb
volt-0.8.14 lib/volt/extra_core/object.rb
volt-0.8.13 lib/volt/extra_core/object.rb
volt-0.8.11 lib/volt/extra_core/object.rb
volt-0.8.10 lib/volt/extra_core/object.rb
volt-0.8.9 lib/volt/extra_core/object.rb
volt-0.8.8 lib/volt/extra_core/object.rb