lib/jss/api_object/advanced_search.rb in ruby-jss-1.3.3 vs lib/jss/api_object/advanced_search.rb in ruby-jss-1.4.1
- old
+ new
@@ -60,10 +60,11 @@
include JSS::Creatable
include JSS::Updatable
include JSS::Criteriable
include JSS::Sitable
+
# Class Constants
#####################################
EXPORT_FORMATS = %i[csv tab xml].freeze
@@ -83,22 +84,39 @@
# The other keys correspond to the {AdvancedSearch#display_fields} defined for this
# Advanced Search.
#
attr_reader :search_results
+ # @return [Array<String>] the fields to be returned with the search results
+ #
+ # The API delivers these as an array of Hashes,
+ # where each hash has only one key, :name => the name of the fields/ExtAttrib
+ # to display. It should probably not have the underlying Hashes, and just
+ # be an array of names. This class converts it to just an Array of field names
+ # (Strings) for internal use.
+ #
+ # These fields are returned in the @search_results
+ # data along with :id, :name, and other unique identifiers
+ # for each found item. In that data, their names have colons removed, abd
+ # spaces and dashes converted to underscores, and they are
+ # symbolized. See attribute result_display_keys
+ #
+ attr_reader :display_fields
+
# @return [Array<Symbol>]
#
# The search result Hash keys for the {#display_fields} of the search
#
# The field names in {#display_fields} are strings matching how the field is labeled
# in the web UI (including the names of Extension Attributes). They have to be that way
# when submitting them to the API, and thats mostly what {#display_fields} and related
# methods are for.
#
# However, when those names come back as the Hash Keys of the {#search_results}
- # they (inconsistently) have spaces and/or dashes converted to underscores, and,
- # the JSON module converts the keys to Symbols, so they don't match the {#display_fields}.
+ # they (inconsistently) have spaces and/or dashes converted to underscores,
+ # and colons are removed. The JSON module then converts the keys to Symbols,
+ # so they don't match the {#display_fields}.
#
# For example, the display field "Last Check-in" might come back as any of these Symbols:
# - :"Last Check-in"
# - :Last_Check_in
# - :"Last_Check-in"
@@ -145,17 +163,17 @@
end
# make sure each hash of the search results
# has a key matching a standard key.
#
- @search_results.each do |hash|
- hash.keys.each do |key|
- std_key = key.to_s.gsub(/ |-/, '_').to_sym
- next if hash[std_key]
- hash[std_key] = hash[key]
- end
- end
+ # @search_results.each do |hash|
+ # hash.keys.each do |key|
+ # std_key = key.to_s.gsub(':', '').gsub(/ |-/, '_').to_sym
+ # next if hash[std_key]
+ # hash[std_key] = hash[key]
+ # end
+ # end
end # init
# Public Instance Methods
#####################################
@@ -228,26 +246,9 @@
ensure
@api.timeout = orig_timeout
@api.open_timeout = orig_open_timeout
end
end
-
- # @return [Array<String>] the fields to be returned with the search results
- #
- # The API delivers these as an array of Hashes,
- # where each hash has only one key, :name => the name of the fields/ExtAttrib
- # to display. It should probably not have the underlying Hashes, and just
- # be an array of names. This class converts it to just an Array of field names
- # (Strings) for internal use.
- #
- # These fields are returned in the @search_results
- # data along with :id, :name, and other unique identifiers
- # for each found item. In that data, their names have
- # spaces and dashes converted to underscores, and they are
- # symbolized.
- #
- #
- attr_reader :display_fields
# Set the list of fields to be retrieved with the
# search results.
#
# @param new_val[Array<String>] the new field names