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



41
42
43
# File 'lib/datacite/mapping/read_only_nodes.rb', line 41

def self.warn(warning)
  super
end

Instance Method Details

#obj_to_xml(obj, _xml)



28
29
30
31
32
# File 'lib/datacite/mapping/read_only_nodes.rb', line 28

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

#value_from(obj)



19
20
21
# File 'lib/datacite/mapping/read_only_nodes.rb', line 19

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

#value_str(val)



23
24
25
26
# File 'lib/datacite/mapping/read_only_nodes.rb', line 23

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

#warn_ignored(val)



34
35
36
37
38
# File 'lib/datacite/mapping/read_only_nodes.rb', line 34

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

#warn_reason



15
16
17
# File 'lib/datacite/mapping/read_only_nodes.rb', line 15

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