Class: Portlet
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Portlet
show all
- Defined in:
- app/models/portlet.rb
Instance Attribute Summary collapse
-
#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.
-
#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.
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
|
Class Method Details
.columns_for_index ⇒ Object
98
99
100
101
102
|
# File 'app/models/portlet.rb', line 98
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
57
58
59
|
# File 'app/models/portlet.rb', line 57
def self.content_block_type
"portlet"
end
|
.content_block_type_for_list ⇒ Object
61
62
63
|
# File 'app/models/portlet.rb', line 61
def self.content_block_type_for_list
"portlet"
end
|
.default_template ⇒ Object
74
75
76
77
78
79
80
|
# File 'app/models/portlet.rb', line 74
def self.default_template
template_file = ActionController::Base.view_paths.map do |vp|
path = vp.to_s.first == "/" ? vp.to_s : File.join(Rails.root, vp.to_s)
File.join(path, default_template_path)
end.detect{|f| File.exists? f }
template_file ? open(template_file){|f| f.read } : ""
end
|
.default_template_path ⇒ Object
86
87
88
|
# File 'app/models/portlet.rb', line 86
def self.default_template_path
@default_template_path ||= "portlets/#{name.tableize.sub('_portlets','')}/render.html.erb"
end
|
70
71
72
|
# File 'app/models/portlet.rb', line 70
def self.form
"portlets/#{name.tableize.sub('_portlets','')}/form"
end
|
.get_subclass(type) ⇒ Object
52
53
54
55
|
# File 'app/models/portlet.rb', line 52
def self.get_subclass(type)
raise "Unknown Portlet Type" unless types.map(&:name).include?(type)
type.constantize
end
|
.has_edit_link? ⇒ Boolean
43
44
45
|
# File 'app/models/portlet.rb', line 43
def self.has_edit_link?
false
end
|
.inherited(subclass) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'app/models/portlet.rb', line 9
def self.inherited(subclass)
super if defined? super
ensure
( @subclasses ||= [] ).push(subclass).uniq!
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
|
.load_portlets ⇒ Object
In Rails, Classes aren’t loaded until you ask for them This method will load all portlets that are defined in a app/portlets directory on the load path
35
36
37
38
39
40
41
|
# File 'app/models/portlet.rb', line 35
def self.load_portlets
ActiveSupport::Dependencies.load_paths.each do |d|
if d =~ /app\/portlets/
Dir["#{d}/*_portlet.rb"].each{|p| require_dependency(p) }
end
end
end
|
.set_default_template_path(s) ⇒ Object
82
83
84
|
# File 'app/models/portlet.rb', line 82
def self.set_default_template_path(s)
@default_template_path = s
end
|
.types ⇒ Object
47
48
49
50
|
# File 'app/models/portlet.rb', line 47
def self.types
load_portlets
@subclasses || []
end
|
Instance Method Details
#inline_options ⇒ Object
90
91
92
|
# File 'app/models/portlet.rb', line 90
def inline_options
{:inline => self.template}
end
|
#instance_name ⇒ Object
104
105
106
|
# File 'app/models/portlet.rb', line 104
def instance_name
"#{self.class.name.demodulize.underscore}_#{id}"
end
|
#portlet_type_name ⇒ Object
66
67
68
|
# File 'app/models/portlet.rb', line 66
def portlet_type_name
type.titleize
end
|
#type_name ⇒ Object
94
95
96
|
# File 'app/models/portlet.rb', line 94
def type_name
type.to_s.titleize
end
|