Class: Cambium::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cambium::Page
show all
- Includes:
- PgSearch, Publishable
- Defined in:
- app/models/cambium/page.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#formatted_active_date, #formatted_active_time, #formatted_date, #formatted_inactive_date, #formatted_inactive_time, #publish!, #published?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *arguments, &block) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'app/models/cambium/page.rb', line 55
def method_missing(method, *arguments, &block)
if respond_to?(method.to_s)
if template.fields[method.to_s.gsub(/\?$/, '')]['type'] == 'boolean'
template_data[method.to_s.gsub(/\?$/, '')].to_i == 1
elsif template.fields[method.to_s]['type'] == 'media'
Cambium::Document.find_by_id(template_data[method.to_s].to_i)
else
template_data[method.to_s]
end
else
super
end
end
|
Class Method Details
.home ⇒ Object
—————————————— Class Methods
29
30
31
|
# File 'app/models/cambium/page.rb', line 29
def self.home
where(:is_home => true).published.first
end
|
Instance Method Details
#body ⇒ Object
43
44
45
|
# File 'app/models/cambium/page.rb', line 43
def body
html.html_safe
end
|
#path_preview ⇒ Object
47
48
49
|
# File 'app/models/cambium/page.rb', line 47
def path_preview
"<a href='#{page_path}' target='_blank'>#{page_path}</a>".html_safe
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
69
70
71
72
73
74
75
76
77
|
# File 'app/models/cambium/page.rb', line 69
def respond_to?(method, include_private = false)
return true if super
return false if template.blank?
return true if template.fields.keys.include?(method.to_s)
template.fields.each do |name, attrs|
return true if attrs["type"] == 'boolean' && method.to_s == "#{name}?"
end
false
end
|
#template ⇒ Object
39
40
41
|
# File 'app/models/cambium/page.rb', line 39
def template
PageTemplate.find(template_name)
end
|
#title_path ⇒ Object
51
52
53
|
# File 'app/models/cambium/page.rb', line 51
def title_path
path.collect(&:title).join(' : ')
end
|
#to_s ⇒ Object
—————————————— Instance Methods
35
36
37
|
# File 'app/models/cambium/page.rb', line 35
def to_s
title
end
|