lib/pp-adaptive/support/node.rb in pp-adaptive-0.0.6 vs lib/pp-adaptive/support/node.rb in pp-adaptive-1.0.0
- old
+ new
@@ -10,11 +10,11 @@
# In the above, the model gets an Attribute named #child, mapping to a JSON parameter named 'childItem'.
# The object at `model.child` is present by default, and is an object of type Child.
#
# Assigning a Hash directly to the attribute will store an object of the boxed type, based on the elements
# in the Hash.
- class Node < Virtus::Attribute::Object
+ class Node < Virtus::Attribute
# Provide access to the boxed type
attr_reader :type
class << self
# Returns a descendant of Node, boxing the given type
@@ -28,9 +28,10 @@
raise ArgumentError, "Child nodes may only be other JsonModel classes" unless type <= JsonModel
@generated_class_map ||= {}
@generated_class_map[type] ||= Class.new(self) do
default lambda { |m, a| type.new }
+ lazy true
define_method :type do
type
end