Sha256: 35d8c3134767c4a3e5cba72790c275b406359f4330d13d68449c594de4648b35

Contents?: true

Size: 613 Bytes

Versions: 16

Compression:

Stored size: 613 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

  def html_inspect
    inspect.gsub('<', '&lt;').gsub('>', '&gt;')
  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

16 entries across 16 versions & 1 rubygems

Version Path
volt-0.9.1 lib/volt/extra_core/object.rb
volt-0.9.1.pre5 lib/volt/extra_core/object.rb
volt-0.9.1.pre4 lib/volt/extra_core/object.rb
volt-0.9.1.pre3 lib/volt/extra_core/object.rb
volt-0.9.1.pre2 lib/volt/extra_core/object.rb
volt-0.9.1.pre1 lib/volt/extra_core/object.rb
volt-0.9.0 lib/volt/extra_core/object.rb
volt-0.9.0.pre7 lib/volt/extra_core/object.rb
volt-0.9.0.pre6 lib/volt/extra_core/object.rb
volt-0.9.0.pre5 lib/volt/extra_core/object.rb
volt-0.9.0.pre4 lib/volt/extra_core/object.rb
volt-0.9.0.pre3 lib/volt/extra_core/object.rb
volt-0.9.0.pre2 lib/volt/extra_core/object.rb
volt-0.9.0.pre1 lib/volt/extra_core/object.rb
volt-0.8.27.beta9 lib/volt/extra_core/object.rb
volt-0.8.27.beta8 lib/volt/extra_core/object.rb