Class Portlet
In: app/models/portlet.rb
Parent: ActiveRecord::Base

Methods

Attributes

connect_to_container  [RW]  These are here simply to temporarily hold these values Makes it easy to pass them through the process of selecting a portlet type
connect_to_page_id  [RW]  These are here simply to temporarily hold these values Makes it easy to pass them through the process of selecting a portlet type
controller  [RW] 

Public Class methods

[Source]

     # File app/models/portlet.rb, line 97
 97:   def self.columns_for_index
 98:     [ {:label => "Name", :method => :name, :order => "name" },
 99:       {:label => "Type", :method => :type_name, :order => "type" },
100:       {:label => "Updated On", :method => :updated_on_string, :order => "updated_at"} ]
101:   end

[Source]

    # File app/models/portlet.rb, line 56
56:   def self.content_block_type
57:     "portlet"
58:   end

[Source]

    # File app/models/portlet.rb, line 60
60:   def self.content_block_type_for_list
61:     "portlet"
62:   end

[Source]

    # File app/models/portlet.rb, line 73
73:   def self.default_template
74:     template_file = ActionController::Base.view_paths.map do |vp| 
75:       path = vp.to_s.first == "/" ? vp.to_s : Rails.root.join(vp.to_s)
76:       Dir[File.join(path, default_template_path) + '.*']
77:     end.flatten.first
78:     template_file ? open(template_file){|f| f.read } : ""
79:   end

[Source]

    # File app/models/portlet.rb, line 85
85:   def self.default_template_path
86:     @default_template_path ||= "portlets/#{name.tableize.sub('_portlets','')}/render"
87:   end

[Source]

    # File app/models/portlet.rb, line 69
69:   def self.form
70:     "portlets/#{name.tableize.sub('_portlets','')}/form"
71:   end

[Source]

    # File app/models/portlet.rb, line 51
51:   def self.get_subclass(type)
52:     raise "Unknown Portlet Type" unless types.map(&:name).include?(type)
53:     type.constantize 
54:   end

[Source]

    # File app/models/portlet.rb, line 37
37:   def self.has_edit_link?
38:     false
39:   end

[Source]

    # File app/models/portlet.rb, line 31
31:       def self.helper_class
32:         "#{name}Helper".constantize
33:       end

[Source]

    # File app/models/portlet.rb, line 27
27:       def self.helper_path
28:         "app/portlets/helpers/#{name.underscore}_helper.rb"
29:       end

[Source]

    # File app/models/portlet.rb, line 15
15:   def self.inherited(subclass)
16:     super if defined? super
17:   ensure
18:     subclass.class_eval do
19:       
20:       has_dynamic_attributes
21:       
22:       acts_as_content_block(
23:         :versioned => false, 
24:         :publishable => false,
25:         :renderable => {:instance_variable_name_for_view => "@portlet"})
26:       
27:       def self.helper_path
28:         "app/portlets/helpers/#{name.underscore}_helper.rb"
29:       end
30: 
31:       def self.helper_class
32:         "#{name}Helper".constantize
33:       end      
34:     end      
35:   end

[Source]

    # File app/models/portlet.rb, line 81
81:   def self.set_default_template_path(s)
82:     @default_template_path = s
83:   end

[Source]

    # File app/models/portlet.rb, line 41
41:   def self.types
42:     @types ||= ActiveSupport::Dependencies.load_paths.map do |d| 
43:       if d =~ /app\/portlets/
44:         Dir["#{d}/*_portlet.rb"].map do |p| 
45:           File.basename(p, ".rb").classify
46:         end
47:       end
48:     end.flatten.compact.uniq.sort
49:   end

Public Instance methods

[Source]

    # File app/models/portlet.rb, line 89
89:   def inline_options
90:     {:inline => self.template}
91:   end

[Source]

     # File app/models/portlet.rb, line 104
104:   def instance_name
105:     "#{self.class.name.demodulize.underscore}_#{id}"
106:   end

For column in list

[Source]

    # File app/models/portlet.rb, line 65
65:   def portlet_type_name
66:     type.titleize
67:   end

This will convert the errors object into a hash and then store it in the flash under the key #{portlet.instance_name}_errors

[Source]

     # File app/models/portlet.rb, line 130
130:   def store_errors_in_flash(errors)
131:     store_hash_in_flash("#{instance_name}_errors", 
132:       errors.inject({}){|h, (k, v)| h[k] = v; h})
133:   end

[Source]

     # File app/models/portlet.rb, line 135
135:   def store_hash_in_flash(key, hash)
136:     flash[key] = hash.inject(HashWithIndifferentAccess.new) do |p,(k,v)|
137:       unless StringIO === v || Tempfile === v
138:         p[k.to_sym] = v
139:       end
140:       p
141:     end      
142:   end

This will copy all the params from this request into the flash. The key in the flash with be the portlet instance_name and the value will be the hash of all the params, except the params that have values that are a StringIO or a Tempfile will be left out.

[Source]

     # File app/models/portlet.rb, line 124
124:   def store_params_in_flash
125:     store_hash_in_flash instance_name, params
126:   end

[Source]

    # File app/models/portlet.rb, line 93
93:   def type_name
94:     type.to_s.titleize
95:   end

[Source]

     # File app/models/portlet.rb, line 114
114:   def url_for_failure
115:     [params[:failure_url], self.failure_url, request.referer].detect do |e|
116:       !e.blank?
117:     end    
118:   end

[Source]

     # File app/models/portlet.rb, line 108
108:   def url_for_success
109:     [params[:success_url], self.success_url, request.referer].detect do |e|
110:       !e.blank?
111:     end    
112:   end

[Validate]