class Puree::XMLExtractor::Resource
Resource
XML extractor.
Public Class Methods
new(xml)
click to toggle source
Calls superclass method
Puree::XMLExtractor::Base::new
# File lib/puree/xml_extractor/resource.rb, line 9 def initialize(xml) super end
Public Instance Methods
created_at()
click to toggle source
@return [Time, nil]
# File lib/puree/xml_extractor/resource.rb, line 24 def created_at xpath_result = xpath_query_for_single_value('/info/createdDate') Time.parse xpath_result if xpath_result end
created_by()
click to toggle source
@return [String, nil]
# File lib/puree/xml_extractor/resource.rb, line 19 def created_by xpath_query_for_single_value('/info/createdBy') end
id()
click to toggle source
@return [String, nil]
# File lib/puree/xml_extractor/resource.rb, line 41 def id xpath_query_for_single_value '/@pureId' end
model()
click to toggle source
@return [Puree::Model::Resource subclass]
# File lib/puree/xml_extractor/resource.rb, line 14 def model combine_metadata end
modified_at()
click to toggle source
@return [Time, nil]
# File lib/puree/xml_extractor/resource.rb, line 35 def modified_at xpath_result = xpath_query_for_single_value('/info/modifiedDate') Time.parse xpath_result if xpath_result end
modified_by()
click to toggle source
@return [String, nil]
# File lib/puree/xml_extractor/resource.rb, line 30 def modified_by xpath_query_for_single_value('/info/modifiedBy') end
previous_uuids()
click to toggle source
@return [Array<String>]
# File lib/puree/xml_extractor/resource.rb, line 51 def previous_uuids xpath_query_for_multi_value '/info/previousUuids/previousUuid' end
uuid()
click to toggle source
@return [String, nil]
# File lib/puree/xml_extractor/resource.rb, line 46 def uuid xpath_query_for_single_value '/@uuid' end
Private Instance Methods
combine_metadata()
click to toggle source
All metadata @return [Hash]
# File lib/puree/xml_extractor/resource.rb, line 64 def combine_metadata raise 'No model to populate' if !@model @model.id = id @model.uuid = uuid @model.created_by = created_by @model.created_at = created_at @model.modified_by = modified_by @model.modified_at = modified_at @model.previous_uuids = previous_uuids end
xpath_query(path)
click to toggle source
# File lib/puree/xml_extractor/resource.rb, line 57 def xpath_query(path) path_from_root = File.join xpath_root, path @doc.xpath path_from_root end