Sha256: 9f575c6ac59747fb505c0db84b68521969784c28bbb3fcdeb70a2adbf47dbe48

Contents?: true

Size: 880 Bytes

Versions: 15

Compression:

Stored size: 880 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::#{enrollable_type}" unless enrollable_type&.include? 'BridgeCache::'
    end

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

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

    def self.format_import_row(row)
      json = 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

15 entries across 15 versions & 1 rubygems

Version Path
bridge_cache-0.5.0 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.4.9 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.4.8 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.4.7 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.4.6 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.4.5 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.4.4 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.4.3 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.4.2 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.4.1 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.24 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.23 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.22 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.21 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.20 app/models/bridge_cache/enrollment_profile.rb