lib/structure/double.rb in structure-1.0.1 vs lib/structure/double.rb in structure-1.0.2
- old
+ new
@@ -1,6 +1,7 @@
module Structure
+ # ClassMethods
module ClassMethods
def double
klass = Class.new(self)
(
@@ -11,12 +12,13 @@
klass.send(:undef_method, name)
end
klass.module_eval do
def initialize(data = {})
- data.each { |key, value|
+ data.each do |key, value|
+ value.freeze unless value.is_a?(Structure)
instance_variable_set(:"@#{key}", value)
- }
+ end
end
attribute_names.each do |name|
module_eval "def _#{name}; @#{name}; end"
private "_#{name}"