Sha256: 43ef8f184f98124917694b9c7adc5b368c3417e247633ff68adcc9b929e2499b

Contents?: true

Size: 714 Bytes

Versions: 4

Compression:

Stored size: 714 Bytes

Contents

module Promethee::StructureUpgrader::Components
  class Base
    def initialize(data)
      @data = data
      # puts "<#{self.class}> Initialized."

      upgrade
    end

    def upgraded_data
      @upgraded_data
    end

    def upgrade
      @upgraded_data = @data.deep_dup
      return if @upgraded_data['attributes'].empty?

      @upgraded_data['attributes'] = upgraded_attributes.deep_stringify_keys
    end

    def upgraded_attributes
      raise NotImplementedError
    end

    protected

    def string_attribute(*path)
      text = attribute(*path)
      Loofah.fragment(text).text(encode_special_chars: false)
    end

    def attribute(*path)
      @data.dig('attributes', *path)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
promethee-4.0.3 app/services/promethee/structure_upgrader/components/base.rb
promethee-4.0.2 app/services/promethee/structure_upgrader/components/base.rb
promethee-4.0.1 app/services/promethee/structure_upgrader/components/base.rb
promethee-4.0.0 app/services/promethee/structure_upgrader/components/base.rb