Class: Iconly::Icon

Inherits:
ApplicationRecord show all
Extended by:
FriendlyId
Defined in:
app/models/iconly/icon.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_packages(user_id, term = nil) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'app/models/iconly/icon.rb', line 15

def self.all_packages(user_id, term = nil)
  with_package = user_id ? Package.shared_or_owned_by(user_id) : Package.shared
  icons = includes(:package)
          .joins(:package)
          .merge(with_package)
  icons = icons.merge(search(term)) if term.present?
  icons
    .order('iconly_packages.name')
    .group_by(&:package)
end

Instance Method Details

#human_nameObject



34
35
36
# File 'app/models/iconly/icon.rb', line 34

def human_name
  name.humanize(capitalize: false)
end

#markupObject



30
31
32
# File 'app/models/iconly/icon.rb', line 30

def markup
  (contents || '').gsub(']>', '').html_safe
end

#svg_pathObject



26
27
28
# File 'app/models/iconly/icon.rb', line 26

def svg_path
  File.join(Iconly.svg_folder, svg.try(:url) || '')
end