Module: Datacite::Mapping::ReadOnlyNodes

Included in:
ReadOnlyArrayNode, ReadOnlyTextNode
Defined in:
lib/datacite/mapping/read_only_nodes.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.warn(warning)

public to allow testing



39
40
41
# File 'lib/datacite/mapping/read_only_nodes.rb', line 39

def self.warn(warning)
  super
end

Instance Method Details

#obj_to_xml(obj, _xml)



26
27
28
29
30
# File 'lib/datacite/mapping/read_only_nodes.rb', line 26

def obj_to_xml(obj, _xml)
  val = value_from(obj)
  return unless val
  warn_ignored(val)
end

#value_from(obj)



17
18
19
# File 'lib/datacite/mapping/read_only_nodes.rb', line 17

def value_from(obj)
  obj.send(@attrname)
end

#value_str(val)



21
22
23
24
# File 'lib/datacite/mapping/read_only_nodes.rb', line 21

def value_str(val)
  return "[ #{val.map(&:to_s).join(', ')} ]" if val.is_a?(Array)
  "'#{val}'"
end

#warn_ignored(val)



32
33
34
35
36
# File 'lib/datacite/mapping/read_only_nodes.rb', line 32

def warn_ignored(val)
  warning = "ignoring #{@attrname} #{value_str(val)}"
  warning.prepend("#{warn_reason}; ") if warn_reason
  ReadOnlyNodes.warn(warning)
end

#warn_reason



13
14
15
# File 'lib/datacite/mapping/read_only_nodes.rb', line 13

def warn_reason
  @warn_reason ||= @options[:warn_reason]
end