Class: MnoEnterprise::App

Inherits:
BaseResource show all
Defined in:
app/models/mno_enterprise/app.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseResource

#==, base_class, #cache_key, #clear_association_cache, #clear_attribute_changes!, find_by, first, last, #max_updated_column_timestamp, #read_attribute, #reload, #save, #save!, #update, #write_attribute

Methods included from HerExtension::Validations::RemoteUniquenessValidation

included

Class Method Details

.categories(list = nil) ⇒ Object

Return the list of available categories



37
38
39
40
# File 'app/models/mno_enterprise/app.rb', line 37

def self.categories(list = nil)
  app_list = list || self.all.to_a
  app_list.select { |a| a.categories.present? }.map(&:categories).flatten.uniq { |e| e.downcase }.sort
end

Instance Method Details

#refresh_metadata!(metadata_url) ⇒ Object



68
69
70
# File 'app/models/mno_enterprise/app.rb', line 68

def refresh_metadata!()
  self.put(operation: 'refresh_metadata', metadata_url: )
end

#regenerate_api_key!Object



63
64
65
66
# File 'app/models/mno_enterprise/app.rb', line 63

def regenerate_api_key!
  data = self.put(operation: 'regenerate_api_key')
  self.api_key = data[:data][:api_key]
end

#sanitized_descriptionObject

Sanitize the app description E.g.: replace any mention of Maestrano by the tenant name



52
53
54
# File 'app/models/mno_enterprise/app.rb', line 52

def sanitized_description
  @sanitized_description ||= (self.description || '').gsub(/maestrano/i,MnoEnterprise.app_name)
end

#to_audit_eventObject



42
43
44
45
46
47
48
# File 'app/models/mno_enterprise/app.rb', line 42

def to_audit_event
  {
    app_id: id,
    app_nid: nid,
    app_name: name
  }
end