Class: Locomotive::ThemeAsset

Inherits:
Object
  • Object
show all
Includes:
Concerns::Asset::Checksum, Concerns::Asset::Types, Concerns::Shared::SiteScope, Mongoid::Document
Defined in:
app/models/locomotive/theme_asset.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.all_grouped_by_folder(site) ⇒ Object


53
54
55
56
# File 'app/models/locomotive/theme_asset.rb', line 53

def self.all_grouped_by_folder(site)
  assets = site.theme_assets.order_by(:slug.asc)
  assets.group_by { |a| a.folder.split('/').first.to_sym }
end

.checksumsObject


58
59
60
61
62
63
64
# File 'app/models/locomotive/theme_asset.rb', line 58

def self.checksums
  {}.tap do |hash|
    self.only(:local_path, :checksum).each do |asset|
      hash[asset.local_path] = asset.checksum
    end
  end
end

Instance Method Details

#local_path(short = false) ⇒ Object

fields ##


12
# File 'app/models/locomotive/theme_asset.rb', line 12

field :local_path

#sourceObject

validations ##


30
# File 'app/models/locomotive/theme_asset.rb', line 30

validates_presence_of   :source, on: :create

#stylesheet_or_javascript?Boolean

Returns:


41
42
43
# File 'app/models/locomotive/theme_asset.rb', line 41

def stylesheet_or_javascript?
  self.stylesheet? || self.javascript?
end

#touch_site_attributeObject

methods ##


37
38
39
# File 'app/models/locomotive/theme_asset.rb', line 37

def touch_site_attribute
  :template_version
end