Class: Web::Portlet
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Web::Portlet
- Defined in:
- lib/web/portlet.rb
Overview
Adds Caterpillar portlets to available portlets.
Constant Summary collapse
- @@caterpillar_portlets =
nil
Class Method Summary collapse
- .caterpillar_portlets ⇒ Object
-
.find_by_name(name) ⇒ Object
searches both Liferay and Caterpillar portlets TODO: DRY up with super.
- .find_caterpillar_portlet(name) ⇒ Object
Class Method Details
.caterpillar_portlets ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/web/portlet.rb', line 10 def self.caterpillar_portlets return @@caterpillar_portlets if @@caterpillar_portlets config = Caterpillar::Util.eval_configuration config.routes = Caterpillar::Util.parse_routes(config) # transform objects portlets = [] Caterpillar::Parser.new(config).portlets.each do |p| portlets << self.new( :portletid => p[:name].to_s ) end @@caterpillar_portlets = portlets end |
.find_by_name(name) ⇒ Object
searches both Liferay and Caterpillar portlets TODO: DRY up with super
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/web/portlet.rb', line 40 def self.find_by_name(name) begin pp = Web::PortletProperties.find_by_name(name) if pp p = self.find_by_portletid pp.portletid return p if p end pp = find_caterpillar_portlet(name) unless pp unless pp raise ActiveRecord::RecordNotFound else return self.create( :portletid => pp.portletid ) end rescue STDERR.puts 'Portlet by name "%s" could not be found -- try "caterpillar db:migrate"' % name logger.debug $!. return nil end end |
.find_caterpillar_portlet(name) ⇒ Object
27 28 29 30 |
# File 'lib/web/portlet.rb', line 27 def self.find_caterpillar_portlet(name) self.caterpillar_portlets.select{ |p| p.name=='%s' % name }.first # find_by_name end |