Class: Object

Inherits:
BasicObject
Includes:
PP::ObjectMixin
Defined in:
lib/pp.rb,
lib/mkmf.rb,
lib/minitest/spec.rb,
lib/yaml/rubytypes.rb,
lib/rexml/xpath_parser.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from PP::ObjectMixin

#pretty_print, #pretty_print_cycle, #pretty_print_inspect, #pretty_print_instance_variables

Class Method Details

+ (Object) yaml_new(val)



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/yaml/rubytypes.rb', line 44

def self.yaml_new(val)
  obj = self.alloc
  if obj.respond_to?(:yaml_initialize)
    obj.yaml_initialize(taguri, val)
  else
    val.each do |k, v|
      obj.instance_variable_set("@#{k}", v)
    end
  end
  obj
end

Instance Method Details

- (Object) dclone



8
9
10
# File 'lib/rexml/xpath_parser.rb', line 8

def dclone
  clone
end

- (Object) to_yaml(output = nil)



33
34
35
36
37
38
39
40
41
42
# File 'lib/yaml/rubytypes.rb', line 33

def to_yaml(output = nil)
  YAML::quick_emit(output) do |out|
    out.map(taguri, to_yaml_style) do |map|
      to_yaml_properties.each do |m|
        # The [1..-1] strips the @ from the variable name.
        out.add(m[1..-1], instance_variable_get(m))
      end
    end
  end
end

- (Object) to_yaml_properties



29
30
31
# File 'lib/yaml/rubytypes.rb', line 29

def to_yaml_properties
  self.instance_variables.sort
end

- (Object) to_yaml_style

yaml_as "tag:ruby.yaml.org,2002:object"



25
26
27
# File 'lib/yaml/rubytypes.rb', line 25

def to_yaml_style
  nil
end

- (Object) yaml_as(tag)



13
14
15
16
17
18
19
20
21
# File 'lib/yaml/rubytypes.rb', line 13

def yaml_as(tag)
  klass = (self.is_a? Class) ? self : (class << self; self; end)
  klass.instance_eval do
    define_method(:taguri) do
      @taguri || tag
    end
  end
  YAML::LibYAML::DEFAULT_RESOLVER.add_type(tag, self)
end