lib/lutaml/model/attribute.rb in lutaml-model-0.3.11 vs lib/lutaml/model/attribute.rb in lutaml-model-0.3.12

- old
+ new

@@ -5,17 +5,22 @@ def initialize(name, type, options = {}) @name = name @type = cast_type(type) @options = options + @raw = !!options[:raw] if collection? validate_collection_range @options[:default] = -> { [] } unless options[:default] end end + def delegate + @options[:delegate] + end + def cast_type(type) case type when Class type when String @@ -43,11 +48,17 @@ def singular? !collection? end + def raw? + @raw + end + def default - value = if options[:default].is_a?(Proc) + value = if delegate + type.attributes[to].default + elsif options[:default].is_a?(Proc) options[:default].call else options[:default] end