Class: Syck::SpecialHash

Inherits:
Hash show all
Defined in:
lib/syck/types.rb

Overview

YAML Hash class to support comments and defaults

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Hash

#yaml_initialize

Instance Attribute Details

#defaultObject

Returns the value of attribute default



62
63
64
# File 'lib/syck/types.rb', line 62

def default
  @default
end

Instance Method Details

#inspectObject



63
64
65
# File 'lib/syck/types.rb', line 63

def inspect
    self.default.to_s
end

#to_sObject



66
67
68
# File 'lib/syck/types.rb', line 66

def to_s
    self.default.to_s
end

#to_yaml(opts = {}) ⇒ Object



75
76
77
78
# File 'lib/syck/types.rb', line 75

def to_yaml( opts = {} )
    opts[:DefaultKey] = self.default
    super( opts )
end

#update(h) ⇒ Object



69
70
71
72
73
74
# File 'lib/syck/types.rb', line 69

def update( h )
    if Syck::SpecialHash === h
        @default = h.default if h.default
    end
    super( h )
end