Class: Cmsimple::PageResponder
- Inherits:
-
Object
- Object
- Cmsimple::PageResponder
- Defined in:
- lib/cmsimple/page_responder.rb
Instance Method Summary collapse
- #current_page_is_viewable? ⇒ Boolean
- #draft_context? ⇒ Boolean
-
#initialize(controller) ⇒ PageResponder
constructor
A new instance of PageResponder.
- #is_currently_editable? ⇒ Boolean
- #page_for_context ⇒ Object
- #published_context? ⇒ Boolean
- #respond ⇒ Object
- #version_context? ⇒ Boolean
Constructor Details
#initialize(controller) ⇒ PageResponder
Returns a new instance of PageResponder.
3 4 5 6 7 8 |
# File 'lib/cmsimple/page_responder.rb', line 3 def initialize(controller) @controller = controller @request = @controller.request @params = @request.params @page = @controller.current_page end |
Instance Method Details
#current_page_is_viewable? ⇒ Boolean
38 39 40 |
# File 'lib/cmsimple/page_responder.rb', line 38 def current_page_is_viewable? is_currently_editable? || @page.published? end |
#draft_context? ⇒ Boolean
34 35 36 |
# File 'lib/cmsimple/page_responder.rb', line 34 def draft_context? @page end |
#is_currently_editable? ⇒ Boolean
42 43 44 |
# File 'lib/cmsimple/page_responder.rb', line 42 def is_currently_editable? @controller.in_editor_iframe? end |
#page_for_context ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/cmsimple/page_responder.rb', line 14 def page_for_context raise ActiveRecord::RecordNotFound unless current_page_is_viewable? return published_context? || version_context? || draft_context? end |
#published_context? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/cmsimple/page_responder.rb', line 22 def published_context? unless is_currently_editable? return @page if @page.as_published! end end |
#respond ⇒ Object
10 11 12 |
# File 'lib/cmsimple/page_responder.rb', line 10 def respond @controller.respond_with page_for_context end |
#version_context? ⇒ Boolean
28 29 30 31 32 |
# File 'lib/cmsimple/page_responder.rb', line 28 def version_context? if @params[:version].present? return @page if @page.at_version!(@params[:version]) end end |