Sha256: e3d4cdc57a79bccf2d92f8844e4024fd3aba7d2dcf707d6fd81042d81ad3d0da

Contents?: true

Size: 843 Bytes

Versions: 2

Compression:

Stored size: 843 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.class.parse_config(row['config'])
      row['config'] = json if json.present?
      row
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bridge_cache-0.3.6 app/models/bridge_cache/enrollment_profile.rb
bridge_cache-0.3.5 app/models/bridge_cache/enrollment_profile.rb