lib/onoma/nomenclature.rb
# Add an item to the nomenclature from an XML element
Add an item to the nomenclature from an XML element
Add an item to the nomenclature from an XML element
def harvest_item(element, attributes = {})
      name = element.attr('name').to_s
      parent = attributes[:parent] || (element.key?('parent') ? element['parent'] : nil)
      attributes = element.attributes.each_with_object(HashWithIndifferentAccess.new) do |(k, v), h|
        next if %w[name parent].include?(k)
        h[k] = cast_property(k, v.to_s)
      end
      attributes[:parent] = parent if parent
      item = add_item(name, attributes, rebuild: false)
      item
    end
def harvest_item ( element , attributes = { } ) name = element . attr ( 'name' ) . to_s parent = attributes [ :parent ] || ( element . key? ( 'parent' ) ? element [ 'parent' ] : nil ) attributes = element . attributes . each_with_object ( HashWithIndifferentAccess . new ) do | ( k , v ) , h | next if %w[ name parent ] . include? ( k ) h [ k ] = cast_property ( k , v . to_s ) end attributes [ :parent ] = parent if parent item = add_item ( name , attributes , rebuild : false ) item end
Add an item to the nomenclature from an XML element
Add an item to the nomenclature from an XML element
element
<not_specific>
attributes
<not_specific>