Class: Mapricot::HasOneAssociation

Inherits:
Association show all
Defined in:
lib/mapricot/associations.rb

Constant Summary

Constants inherited from Association

Association::VALID_TYPES

Instance Attribute Summary

Attributes inherited from Association

#name, #namespace, #type, #value

Instance Method Summary collapse

Methods inherited from Association

#initialize, #tag_name

Constructor Details

This class inherits a constructor from Mapricot::Association

Instance Method Details

#set_value_from_node_list(node_list) ⇒ Object

pass a node list, depending on the type of association



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/mapricot/associations.rb', line 66

def set_value_from_node_list(node_list)
  if node_list.empty?
    @value = nil
  else
    if @type == :xml
     @value = class_from_name.new(node_list.first.to_s)
    else
      @value = node_list.first.contents
      typecast
    end
  end
end