Sha256: d743fbd9c4341a4b94a15c83e77f7633c1e9205a4260e8c958c8093243b548bd

Contents?: true

Size: 804 Bytes

Versions: 62

Compression:

Stored size: 804 Bytes

Contents

module Workarea
  module Search
    class HashText
      attr_reader :hash

      def initialize(hash)
        @hash = hash || {}
      end

      # Flatten out all values in the hash and
      # returns a comma-delimited string. Used for
      # entering catalog Hash data into the search index
      # for full text searching.
      #
      # @return [String]
      #
      def text
        hash.map do |key, value|
          value_string = if value.is_a?(Hash)
                           HashText.new(value).text
                         elsif value.is_a?(Array)
                           value.join(', ')
                         else
                           value
                         end

          "#{key.to_s.humanize}: #{value_string}"
        end.join('; ')
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/search/hash_text.rb
workarea-core-3.5.26 app/models/workarea/search/hash_text.rb
workarea-core-3.4.45 app/models/workarea/search/hash_text.rb
workarea-core-3.5.25 app/models/workarea/search/hash_text.rb
workarea-core-3.5.23 app/models/workarea/search/hash_text.rb
workarea-core-3.4.44 app/models/workarea/search/hash_text.rb
workarea-core-3.5.22 app/models/workarea/search/hash_text.rb
workarea-core-3.4.43 app/models/workarea/search/hash_text.rb
workarea-core-3.5.21 app/models/workarea/search/hash_text.rb
workarea-core-3.4.42 app/models/workarea/search/hash_text.rb
workarea-core-3.5.20 app/models/workarea/search/hash_text.rb
workarea-core-3.4.41 app/models/workarea/search/hash_text.rb
workarea-core-3.5.19 app/models/workarea/search/hash_text.rb
workarea-core-3.4.40 app/models/workarea/search/hash_text.rb
workarea-core-3.5.18 app/models/workarea/search/hash_text.rb
workarea-core-3.4.39 app/models/workarea/search/hash_text.rb
workarea-core-3.5.17 app/models/workarea/search/hash_text.rb
workarea-core-3.4.38 app/models/workarea/search/hash_text.rb
workarea-core-3.5.16 app/models/workarea/search/hash_text.rb
workarea-core-3.4.37 app/models/workarea/search/hash_text.rb