def sitemap_capture_attributes(attributes = {})
      values = {}

      attributes.each do |pair|

        # if the value of the pair is a Symbol, then, it is implied to be
        # an attribute of the object we are working on.
        # therefore, we will attempt to get the value of that attribute from the object.
        if pair.last.kind_of?(Symbol)

          # if the object has the attribute/method we are looking for, then, capture the value
          # by calling the attribute/method and assign the return value to the return Hash
          # using pair.first as the key.
          if self.respond_to?(pair.last)

            # ask the object for the attribute value
            value = self.send(pair.last)

            # ignore nil values
            unless value.blank?
              values[pair.first] = value
            end

          end

        elsif !pair.last.blank?
          values[pair.first] = pair.last
        end

      end

      return values
    end
def sitemap_capture_attributes(attributes = {})
      values = {}

      attributes.each do |pair|

        # if the value of the pair is a Symbol, then, it is implied to be
        # an attribute of the object we are working on.
        # therefore, we will attempt to get the value of that attribute from the object.
        if pair.last.kind_of?(Symbol)

          # if the object has the attribute/method we are looking for, then, capture the value
          # by calling the attribute/method and assign the return value to the return Hash
          # using pair.first as the key.
          if self.respond_to?(pair.last)

            # ask the object for the attribute value
            value = self.send(pair.last)

            # ignore nil values
            unless value.blank?
              values[pair.first] = value
            end

          end

        elsif !pair.last.blank?
          values[pair.first] = pair.last
        end

      end

      return values
    end
Returns a Hash containing key/value pairs from the current object.

 This method loops through all of the key/value pairs contained in the attributes Hash.

 Each pair is inspected.
 - if the value is a Symbol
   - the current object is asked if it has a matching method name matching the value.
     - if true, then, the method is called to obtain a value.
       - if the new value is NOT nil, then, it is paired with the key of the current pair being processed
         and assigned to the returning Hash.
 - otherwise, if the value is not nil, then, it is considered to be a static value and is assigned to the
   returning Hash using the key of the current pair being processed.

    # let's pretend this class exists and has the following attributes.
    object = MyObject.new
    object.my_title = "my title"
    object.tags = "this that other"
    object.content = "this is a test"
    object.last_updated_at = Time.now

    attributes = {title: :my_title,
                  keywords: nil,
                  description: "this is my desc",
                  lastmod: :invalid_method_name}

    values = object.sitemap_capture_attributes(attributes)

    puts YAML.dump values        # => {title => "my title", description => "this is my desc"}

 The result:
 - :my_title is a Symbol and attribute exists on object and value is not nil, so, it is included in the returning Hash.
 - :keywords is nil, so, it is ignored and not included in the returning Hash.
 - :description is a String and considered a static value, so, it is included in the returning Hash "as is".
 - :my_title is a Symbol, however, a matching attribute/method does NOT exist on the target object, so,
   it is ignored and not included in the returning Hash.

 @param [Hash] attributes Options hash. Can be any combination of key/value pairs (one-dimensional).
 return [Hash]