code: def to_hash
        self.class.attribute_names.inject({}) do |hash, name|
          val = format_value(send(name.underscore))
          val.empty? ? hash : hash.merge(format_key(name) => val)
        end
      end
docs: Formats all attributes into a hash of parameters.