Class: Portlet
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Portlet
show all
- Defined in:
- app/models/portlet.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#connect_to_container ⇒ Object
These are here simply to temporarily hold these values Makes it easy to pass them through the process of selecting a portlet type
7
8
9
|
# File 'app/models/portlet.rb', line 7
def connect_to_container
@connect_to_container
end
|
#connect_to_page_id ⇒ Object
These are here simply to temporarily hold these values Makes it easy to pass them through the process of selecting a portlet type
7
8
9
|
# File 'app/models/portlet.rb', line 7
def connect_to_page_id
@connect_to_page_id
end
|
#controller ⇒ Object
Returns the value of attribute controller.
9
10
11
|
# File 'app/models/portlet.rb', line 9
def controller
@controller
end
|
Class Method Details
.columns_for_index ⇒ Object
97
98
99
100
101
|
# File 'app/models/portlet.rb', line 97
def self.columns_for_index
[ {:label => "Name", :method => :name, :order => "name" },
{:label => "Type", :method => :type_name, :order => "type" },
{:label => "Updated On", :method => :updated_on_string, :order => "updated_at"} ]
end
|
.content_block_type ⇒ Object
56
57
58
|
# File 'app/models/portlet.rb', line 56
def self.content_block_type
"portlet"
end
|
.content_block_type_for_list ⇒ Object
60
61
62
|
# File 'app/models/portlet.rb', line 60
def self.content_block_type_for_list
"portlet"
end
|
.default_template ⇒ Object
73
74
75
76
77
78
79
|
# File 'app/models/portlet.rb', line 73
def self.default_template
template_file = ActionController::Base.view_paths.map do |vp|
path = vp.to_s.first == "/" ? vp.to_s : Rails.root.join(vp.to_s)
Dir[File.join(path, default_template_path) + '.*']
end.flatten.first
template_file ? open(template_file){|f| f.read } : ""
end
|
.default_template_path ⇒ Object
85
86
87
|
# File 'app/models/portlet.rb', line 85
def self.default_template_path
@default_template_path ||= "portlets/#{name.tableize.sub('_portlets','')}/render"
end
|
69
70
71
|
# File 'app/models/portlet.rb', line 69
def self.form
"portlets/#{name.tableize.sub('_portlets','')}/form"
end
|
.get_subclass(type) ⇒ Object
51
52
53
54
|
# File 'app/models/portlet.rb', line 51
def self.get_subclass(type)
raise "Unknown Portlet Type" unless types.map(&:name).include?(type)
type.constantize
end
|
.has_edit_link? ⇒ Boolean
37
38
39
|
# File 'app/models/portlet.rb', line 37
def self.has_edit_link?
false
end
|
.inherited(subclass) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/models/portlet.rb', line 15
def self.inherited(subclass)
super if defined? super
ensure
subclass.class_eval do
has_dynamic_attributes
acts_as_content_block(
:versioned => false,
:publishable => false,
:renderable => {:instance_variable_name_for_view => "@portlet"})
def self.helper_path
"app/portlets/helpers/#{name.underscore}_helper.rb"
end
def self.helper_class
"#{name}Helper".constantize
end
end
end
|
.set_default_template_path(s) ⇒ Object
81
82
83
|
# File 'app/models/portlet.rb', line 81
def self.set_default_template_path(s)
@default_template_path = s
end
|
.types ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'app/models/portlet.rb', line 41
def self.types
@types ||= ActiveSupport::Dependencies.load_paths.map do |d|
if d =~ /app\/portlets/
Dir["#{d}/*_portlet.rb"].map do |p|
File.basename(p, ".rb").classify
end
end
end.flatten.compact.uniq.sort
end
|
Instance Method Details
#inline_options ⇒ Object
89
90
91
|
# File 'app/models/portlet.rb', line 89
def inline_options
{:inline => self.template}
end
|
#instance_name ⇒ Object
—– Portlet Action Related Methods —————————————-
104
105
106
|
# File 'app/models/portlet.rb', line 104
def instance_name
"#{self.class.name.demodulize.underscore}_#{id}"
end
|
#portlet_type_name ⇒ Object
65
66
67
|
# File 'app/models/portlet.rb', line 65
def portlet_type_name
type.titleize
end
|
#store_errors_in_flash(errors) ⇒ Object
This will convert the errors object into a hash and then store it in the flash under the key #Portlet.portletportlet.instance_name_errors
130
131
132
133
|
# File 'app/models/portlet.rb', line 130
def store_errors_in_flash(errors)
store_hash_in_flash("#{instance_name}_errors",
errors.inject({}){|h, (k, v)| h[k] = v; h})
end
|
#store_hash_in_flash(key, hash) ⇒ Object
135
136
137
138
139
140
141
142
|
# File 'app/models/portlet.rb', line 135
def store_hash_in_flash(key, hash)
flash[key] = hash.inject(HashWithIndifferentAccess.new) do |p,(k,v)|
unless StringIO === v || Tempfile === v
p[k.to_sym] = v
end
p
end
end
|
#store_params_in_flash ⇒ Object
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.
124
125
126
|
# File 'app/models/portlet.rb', line 124
def store_params_in_flash
store_hash_in_flash instance_name, params
end
|
#type_name ⇒ Object
93
94
95
|
# File 'app/models/portlet.rb', line 93
def type_name
type.to_s.titleize
end
|
#url_for_failure ⇒ Object
114
115
116
117
118
|
# File 'app/models/portlet.rb', line 114
def url_for_failure
[params[:failure_url], self.failure_url, request.referer].detect do |e|
!e.blank?
end
end
|
#url_for_success ⇒ Object
108
109
110
111
112
|
# File 'app/models/portlet.rb', line 108
def url_for_success
[params[:success_url], self.success_url, request.referer].detect do |e|
!e.blank?
end
end
|