diff --git a/lib/relaton/bib/formattedref.rb b/lib/relaton/bib/formattedref.rb
index dcacbee..7ea146e 100644
--- a/lib/relaton/bib/formattedref.rb
+++ b/lib/relaton/bib/formattedref.rb
@@ -2,26 +2,12 @@ module Relaton
module Bib
class Formattedref
# @return [String]
- attr_reader :content
+ attr_accessor :content
def initialize(content: nil)
@content = content
end
- def content=(content)
- @content = content.is_a?(String) ? content : content.to_xml
- end
-
- # @param content [Relaton::M
- # def content=(content)
- # @content = content.is_a?(String) ? Model::TextElement.from_xml(content) : content
- # end
-
- # @param [Nokogiri::XML::Builder]
- # def to_xml(builder)
- # builder.formattedref { super }
- # end
-
# @param prefix [String]
# @return [String]
def to_asciibib(prefix = "")
diff --git a/lib/relaton/model/formattedref.rb b/lib/relaton/model/formattedref.rb
index 1a203c1..e23a2af 100644
--- a/lib/relaton/model/formattedref.rb
+++ b/lib/relaton/model/formattedref.rb
@@ -4,37 +4,11 @@ class Formattedref < Lutaml::Model::Serializable
model Bib::Formattedref
- attribute :content, TextElement # , collection: true
+ attribute :content, :string
xml do
root "formattedref"
- map_content to: :text, delegate: :content # , with: { to: :content_to_xml, from: :content_from_xml }
- map_element "em", to: :em, delegate: :content # , with: { to: :em_to_xml, from: :em_from_xml }
- map_element "strong", to: :strong, delegate: :content # , with: { to: :strong_to_xml, from: :strong_from_xml }
- end
-
- def content_to_xml(model, parent, doc)
- parent << doc.create_element("content", model.content)
- end
-
- def content_from_xml(model, value)
- model.content << value
- end
-
- def em_from_xml(model, value)
- model.content << value.to_xml
- end
-
- def em_to_xml(model, parent, doc)
- parent << doc.create_element("em", model.content)
- end
-
- def strong_from_xml(model, value)
- model.content << value.to_xml
- end
-
- def strong_to_xml(model, parent, doc)
- parent << doc.create_element("strong", model.content)
+ map_all to: :content
end
end
end
diff --git a/spec/relaton/model/formattedref_spec.rb b/spec/relaton/model/formattedref_spec.rb
index 11d5583..2527ac9 100644
--- a/spec/relaton/model/formattedref_spec.rb
+++ b/spec/relaton/model/formattedref_spec.rb
@@ -6,19 +6,7 @@
it "parse XML" do
formattedref = described_class.from_xml xml
expect(formattedref).to be_instance_of Relaton::Bib::Formattedref
- expect(formattedref.content).to be_instance_of Array
- expect(formattedref.content.size).to eq 3
- expect(formattedref.content[0]).to be_instance_of Relaton::Model::TextElement
- expect(formattedref.content[1]).to be_instance_of Relaton::Model::TextElement
- expect(formattedref.content[2]).to be_instance_of Relaton::Model::TextElement
- expect(described_class.to_xml(formattedref)).to be_equivalent_to xml
- end
-
- it "parse XML" do
- formattedref = Relaton::Bib::Formattedref.new
- formattedref.content = "StrongcontentEm"
- expect(formattedref.content).to be_instance_of Array
- expect(formattedref.content.size).to eq 3
+ expect(formattedref.content).to eq "StrongContentEm"
expect(described_class.to_xml(formattedref)).to be_equivalent_to xml
end
end