Sha256: 53c85a3922d79cb639539ea5ef015862153af5838fdd1dad68c4a12485391033

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

module PrometheeData
  extend ActiveSupport::Concern

  def data_page_title
    data['attributes']['searchable_title']
  end

  def data_page_description
    data['attributes']['searchable_description']
  end

  def data=(value)
    value = JSON.parse value if value.is_a? String
    super(value)
  end

  def promethee_data_searchable
    promethee_extract_searchable data
  end

  protected

  include ActionView::Helpers::SanitizeHelper
  def promethee_extract_searchable(component)
    searchable = ' '
    component['attributes'].each do |key, value|
      if key.starts_with? 'searchable_'
        clean_value = strip_tags value
        searchable += "#{clean_value} "
      end
    end if component.include? 'attributes'
    component['children'].each do |child|
      searchable += promethee_extract_searchable child
    end if component.include? 'children'
    # for translations
    component['components'].each do |child|
      searchable += promethee_extract_searchable child
    end if component.include? 'components'
    searchable
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
promethee-1.6.27 app/models/concerns/promethee_data.rb
promethee-1.6.26 app/models/concerns/promethee_data.rb
promethee-1.6.25 app/models/concerns/promethee_data.rb
promethee-1.6.24 app/models/concerns/promethee_data.rb