Class: LesliBabel::Module

Inherits:
ApplicationRecord show all
Defined in:
app/models/lesli_babel/module.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.indexObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/lesli_babel/module.rb', line 10

def self.index 
    Module.where("name is not null")
    order(id: :desc).map do |translation_module|
        {
            id: translation_module[:id],
            name: translation_module[:name],
            code: translation_module[:name].downcase,
            platform: translation_module[:platform]
        }
    end
end

Instance Method Details

#format_module_nameObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/lesli_babel/module.rb', line 22

def format_module_name

    return if self.code == "main_app"
    return if self.platform == "lesli_core"
    return if self.platform == "lesli_engine"

    self.code = self.code
    .gsub(/[^0-9A-Za-z\s\-\_]/, '')  # remove special characters from string
    .gsub(/-/, '')                   # replace dashes with underscore
    .gsub(/_/, '')                   # replace underscore with underscore
    .gsub(/\s+/, '')                 # remove blank spaces
end