Skip to content

Commit

Permalink
Make multiple_allowed? available on all definitions with max occurs
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzobrain committed Apr 17, 2024
1 parent e2b7cee commit 9878bbd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 0 additions & 6 deletions lib/xsd/objects/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ def optional?
!required?
end

# Determine if element may occur multiple times
# @return Boolean
def multiple_allowed?
computed_max_occurs == :unbounded || computed_max_occurs > 1
end

# Determine if element has complex content
# @return Boolean
def complex_content?
Expand Down
6 changes: 6 additions & 0 deletions lib/xsd/shared/min_max_occurs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,11 @@ def computed_min_occurs
min_occurs
end
end

# Determine if element may occur multiple times
# @return Boolean
def multiple_allowed?
computed_max_occurs == :unbounded || computed_max_occurs > 1
end
end
end
5 changes: 4 additions & 1 deletion spec/xsd/xml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
end

it 'returns <xs:any> in collect_elements list' do
expect(reader['ManifestMessage']['FtpMessageHeader']['Signature']['KeyInfo']['X509Data'].collect_elements.last.name).to eq '#any'
element = reader['ManifestMessage']['FtpMessageHeader']['Signature']['KeyInfo']['X509Data'].collect_elements.last

expect(element.name).to eq '#any'
expect(element).to be_multiple_allowed
end
end
end

0 comments on commit 9878bbd

Please sign in to comment.