Sha256: 25a70aeff30aa92a5cbac5695474c4929a0220035acc3781da5b3b2d4377d813

Contents?: true

Size: 908 Bytes

Versions: 7

Compression:

Stored size: 908 Bytes

Contents

module BridgeCache
  class EnrollmentProfile < BridgeBaseModel
    extend BridgeCache::Data::BridgeModel

    belongs_to :enrollable, primary_key: BridgeCache.primary_key, polymorphic: true, optional: true
    before_validation :namespace_enrollable_type
    before_save :parse_json

    def namespace_enrollable_type
      self.enrollable_type = "BridgeCache::#{self.enrollable_type}" unless self.enrollable_type&.include? 'BridgeCache::'
    end

    def parse_json
      json = self.class.parse_config(self.config)
      self.config = json if json.present?
    end

    def self.parse_config(config)
      json = BridgeCache::Plugins::DataTransform::valid_json?(config)
    end

    def self.format_import_row(row)
      json = self.parse_config(row['config'])
      row['config'] = json if json.present?
      row
    end

    def self.unique_column_names
      %w[bridge_id domain_id]
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bridge_cache-0.3.19 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.17 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.16 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.15 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.14 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.13 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.12 app/models/bridge_cache/enrollment_profile.rb