Class PageRoute
In: app/models/page_route.rb
Parent: ActiveRecord::Base

Methods

Public Instance methods

[Source]

    # File app/models/page_route.rb, line 15
15:   def add_condition(name, value)
16:     conditions.build(:name => name.to_s, :value => value.to_s)
17:   end

[Source]

    # File app/models/page_route.rb, line 19
19:   def add_requirement(name, value)
20:     requirements.build(:name => name.to_s, :value => value.to_s)
21:   end

[Source]

    # File app/models/page_route.rb, line 23
23:   def conditions_map
24:     conditions.inject({}){|acc, e| acc[e.name.to_sym] = e.value.to_sym; acc}
25:   end

This is called by an instance of the content controller in the process of rendering a page. This will eval the code stored in this page route in the context of the controller. The main purpose of this method is to set instance variables that will be used by one or more portlets when the page is rendered. To set an instance variable, the code should contain something like:

   @news_article = NewsArticle.find(params[:id]))

[Source]

    # File app/models/page_route.rb, line 54
54:   def execute(controller)
55:     controller.instance_eval(code) unless code.blank?
56:   end

This is used in defining the route in the ActionController::Routing

[Source]

    # File app/models/page_route.rb, line 36
36:   def options_map
37:     m = {:controller => "cms/content", :action => "show_page_route"}
38:     
39:     m[:_page_route_id] = self.id.to_s
40:     
41:     m[:requirements] = requirements_map
42:     m[:conditions] = conditions_map
43:     
44:     m
45:   end

[Source]

    # File app/models/page_route.rb, line 11
11:   def reload_routes
12:     ActionController::Routing::Routes.load!
13:   end

[Source]

    # File app/models/page_route.rb, line 27
27:   def requirements_map
28:     requirements.inject({}){|acc, e| acc[e.name.to_sym] = Regexp.new(e.value); acc}
29:   end

[Source]

    # File app/models/page_route.rb, line 31
31:   def route_name
32:     name ? name.to_slug.gsub('-','_') : nil
33:   end

[Validate]