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)

rubocop:disable Lint/UselessMethodDefinition public to allow testing



44
45
46
# File 'lib/datacite/mapping/read_only_nodes.rb', line 44

def self.warn(warning)
  super
end

Instance Method Details

#obj_to_xml(obj, _xml)



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

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
27
# 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)



36
37
38
39
40
# File 'lib/datacite/mapping/read_only_nodes.rb', line 36

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