Skip to content

Commit

Permalink
fix: Undefined method for Custom model
Browse files Browse the repository at this point in the history
  • Loading branch information
suleman-uzair authored and ronaldtse committed Oct 26, 2024
1 parent 5b82780 commit 95d9f67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/lutaml/model/serialize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def apply_xml_mapping(doc, instance, options = {})
end

defaults_used.each do |attribute_name|
instance.using_default_for(attribute_name)
instance.using_default_for(attribute_name) if instance.respond_to?(:using_default_for)
end

instance
Expand Down
4 changes: 3 additions & 1 deletion spec/lutaml/model/custom_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CustomModelChild
end

class CustomModelParent
attr_accessor :first_name, :last_name, :child_mapper
attr_accessor :first_name, :middle_name, :last_name, :child_mapper

def name
"#{first_name} #{last_name}"
Expand All @@ -28,11 +28,13 @@ class CustomModelParentMapper < Lutaml::Model::Serializable
model CustomModelParent

attribute :first_name, Lutaml::Model::Type::String
attribute :middle_name, Lutaml::Model::Type::String
attribute :last_name, Lutaml::Model::Type::String
attribute :child_mapper, CustomModelChildMapper

xml do
map_element :first_name, to: :first_name
map_element :middle_name, to: :middle_name
map_element :last_name, to: :last_name
map_element :CustomModelChild, with: { to: :child_to_xml, from: :child_from_xml }
end
Expand Down

0 comments on commit 95d9f67

Please sign in to comment.