Class: Object

Inherits:
BasicObject
Defined in:
lib/rcl/ext/yaml_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.persistent(*var) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rcl/ext/yaml_helper.rb', line 26

def self.persistent *var
  for i in (0..var.length-1)
    var[i] = var[i].to_s
  end
  self.persist.concat(var)
  self.persist.uniq!   
end

Instance Method Details

#old_to_yamlObject



34
# File 'lib/rcl/ext/yaml_helper.rb', line 34

alias_method :old_to_yaml, :to_yaml

#to_yaml(opts = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rcl/ext/yaml_helper.rb', line 36

def to_yaml ( opts = {} )       
  p = self.class.persist_with_parent

  if p && p.size > 0
    yaml_emit opts do |map|
      p.each do |m|
        map.add( m, instance_variable_get( '@' + m ) )
      end
    end
  else
    old_to_yaml opts
  end
end