Class: Quadro::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/quadro/page.rb

Constant Summary collapse

PAGE_TEMPLATES_PATH =

constants

'app/views/quadro/shared/templates/'
SITEMAP_FREQUENCY =
%w(always hourly daily weekly monthly yearly never).freeze
SITEMAP_PRIORITY =
[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.short_nameObject



83
84
85
# File 'app/models/quadro/page.rb', line 83

def short_name
  'page'
end

Instance Method Details

#ensure_coverObject



65
66
67
# File 'app/models/quadro/page.rb', line 65

def ensure_cover
  generate_cover if self.cover.nil?
end

#find_asset(asset_id) ⇒ Object



59
60
61
62
63
# File 'app/models/quadro/page.rb', line 59

def find_asset(asset_id)
  new_asset = assets.find(asset_id) rescue nil
  new_asset.becomes(new_asset.type.constantize) unless new_asset.nil?
  new_asset
end

#templatesObject



50
51
52
53
54
55
56
57
# File 'app/models/quadro/page.rb', line 50

def templates
  templates = []
  Dir.glob("#{PAGE_TEMPLATES_PATH}*.html.haml").each do |file|
    file = File.basename(file, '.html.haml')
    templates << file[1..-1] if file.start_with?('_')
  end
  templates
end

#to_paramObject

methods



42
43
44
# File 'app/models/quadro/page.rb', line 42

def to_param
  slug
end

#to_sObject



46
47
48
# File 'app/models/quadro/page.rb', line 46

def to_s
  title
end