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
54
55
56
57
58
59
60
61
62
63
64
|
# File 'app/models/cambium/page.rb', line 54
def method_missing(method, *arguments, &block)
if respond_to?(method.to_s)
if 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
28
29
30
|
# File 'app/models/cambium/page.rb', line 28
def self.home
where(:is_home => true).published.first
end
|
Instance Method Details
#body ⇒ Object
42
43
44
|
# File 'app/models/cambium/page.rb', line 42
def body
html.html_safe
end
|
#path_preview ⇒ Object
46
47
48
|
# File 'app/models/cambium/page.rb', line 46
def path_preview
"<a href='#{page_path}' target='_blank'>#{page_path}</a>".html_safe
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
66
67
68
69
70
71
|
# File 'app/models/cambium/page.rb', line 66
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)
false
end
|
#template ⇒ Object
38
39
40
|
# File 'app/models/cambium/page.rb', line 38
def template
PageTemplate.find(template_name)
end
|
#title_path ⇒ Object
50
51
52
|
# File 'app/models/cambium/page.rb', line 50
def title_path
path.collect(&:title).join(' : ')
end
|
#to_s ⇒ Object
—————————————— Instance Methods
34
35
36
|
# File 'app/models/cambium/page.rb', line 34
def to_s
title
end
|