Sha256: 8862980bb978707bdc7c7d01b52d847699b204d28c95f2a5def3b55971291a86

Contents?: true

Size: 1.13 KB

Versions: 60

Compression:

Stored size: 1.13 KB

Contents

# Injects localization data into master data, so the page can be showed in the correct localization
class Promethee::Data::MasterLocalized < Promethee::Data
  def initialize(master, localization = nil)
    @data = hashify master
    if localization
      @localization = Localization.new localization
      localize_component @data
    end
  end

  protected

  def localize_component(component)
    localize_component_attributes component if component.include?(:attributes)
    localize_component_children component if component.include?(:children)
  end

  def localize_component_attributes(component)
    localized_component = find_localized_component component[:id]
    return if (localized_component.nil? || !localized_component.include?(:attributes))
    component[:attributes].deep_merge_existing_keys! localized_component[:attributes]
  end



  def localize_component_children(component)
    component[:children].each { |child| localize_component child }
  end

  def find_localized_component(id)
    return if @localization.nil? || !@localization.include?(:components)
    @localization[:components].find { |component| component[:id] == id }
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
promethee-5.1.1 lib/promethee/data/master_localized.rb
promethee-5.1.0 lib/promethee/data/master_localized.rb
promethee-5.0.2 lib/promethee/data/master_localized.rb
promethee-5.0.1 lib/promethee/data/master_localized.rb
promethee-5.0.0 lib/promethee/data/master_localized.rb
promethee-4.1.28 lib/promethee/data/master_localized.rb
promethee-4.1.27 lib/promethee/data/master_localized.rb
promethee-4.1.26 lib/promethee/data/master_localized.rb
promethee-4.1.25 lib/promethee/data/master_localized.rb
promethee-4.1.24 lib/promethee/data/master_localized.rb
promethee-4.1.23 lib/promethee/data/master_localized.rb
promethee-4.1.22 lib/promethee/data/master_localized.rb
promethee-4.1.21 lib/promethee/data/master_localized.rb
promethee-4.1.20 lib/promethee/data/master_localized.rb
promethee-4.1.19 lib/promethee/data/master_localized.rb
promethee-4.1.18 lib/promethee/data/master_localized.rb
promethee-4.1.17 lib/promethee/data/master_localized.rb
promethee-4.1.16 lib/promethee/data/master_localized.rb
promethee-4.1.15 lib/promethee/data/master_localized.rb
promethee-4.1.14 lib/promethee/data/master_localized.rb