37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/property/attribute.rb', line 37
def store_properties_in(accessor)
if accessor.nil? || accessor == self
accessor = ''
else
accessor = "#{accessor}."
end
load_and_dump_methods =" private\n @@invalid_property_failover = nil\n \n def load_properties\n raw_data = \#{accessor}read_attribute('properties')\n prop = raw_data ? decode_properties(raw_data) : Properties.new\n # We need to set the owner to access property definitions and enable\n # type casting on write.\n prop.owner = self\n prop\n rescue => err\n if @@invalid_property_failover\n Properties[@@invalid_property_failover]\n else\n raise Property::DecodingError.new err.message\n end\n end\n\n def dump_properties\n if @properties && @properties.changed?\n if [email protected]?\n \#{accessor}write_attribute('properties', encode_properties(@properties))\n else\n \#{accessor}write_attribute('properties', nil)\n end\n @properties.clear_changes!\n end\n true\n end\n \n def self.invalid_property_failover(failover)\n raise \"Invalid failover property value type: should be a Hash.\" unless failover.kind_of?(Hash) || failover == nil\n @@invalid_property_failover = failover\n end\n EOF\n class_eval(load_and_dump_methods, __FILE__, __LINE__)\nend\n"
|