lib/cacofonix/core/element.rb in cacofonix-0.10.1 vs lib/cacofonix/core/element.rb in cacofonix-0.10.2
- old
+ new
@@ -16,11 +16,11 @@
# :singular - accessor is not an array, just a single object.
#
def self.onix_composite(name, klass, options = {})
options[:as] = options.delete(:singular) ? klass : [klass]
options[:from] ||= klass.to_s.split("::").last
- xml_accessor(name, options)
+ xml_accessor(name, **options)
end
# An accessor that treats the input/output as a date.
#
# Options: none yet.
@@ -35,11 +35,11 @@
[vs].flatten.collect { |v| Date.parse(v) rescue nil }
}
else
prep = lambda { |v| Date.parse(v) rescue nil }
end
- xml_accessor(name, options, &prep)
+ xml_accessor(name, **options, &prep)
end
# An accessor that treats the input as a space-separated list, and
# creates an array for it.
#
@@ -47,11 +47,11 @@
options = options.merge(
:from => tag_name,
:to_xml => Cacofonix::Formatters.space_separated
)
prep = lambda { |v| v ? v.split : [] }
- xml_accessor(name, options, &prep)
+ xml_accessor(name, **options, &prep)
end
# An accessor that treats an empty string as a true value -- so that
# something like <NoContributor /> is recognised as
@@ -61,11 +61,11 @@
options = options.merge(
:from => tag_name,
:to_xml => Cacofonix::Formatters.boolean
)
prep = lambda { |v| v ? true : false }
- xml_accessor(name, options, &prep)
+ xml_accessor(name, **options, &prep)
end
# An accessor that maps a "code" string into an Cacofonix::Code object.
# A Code object can return the simple code (or "key"), or the value that
@@ -115,11 +115,11 @@
options.delete(:enforce)
prep = lambda { |value|
Cacofonix::Code.new(list_number, value, code_opts)
}
options = options.merge(:from => tag_name)
- xml_accessor("#{name}_code", options, &prep)
+ xml_accessor("#{name}_code", **options, &prep)
define_method(name) do
send("#{name}_code").key
end
@@ -169,10 +169,10 @@
[values].flatten.collect do |data|
Cacofonix::Code.new(list_number, data, code_opts)
end
}
options = options.merge(:from => tag_name, :as => [])
- xml_accessor("#{name}_codes", options, &prep)
+ xml_accessor("#{name}_codes", **options, &prep)
define_method(name) do
codes = send("#{name}_codes")
codes ? codes.collect { |cd| cd.key } : nil
end