Sha256: ee943424e3234fdc0d405c866300bb3116ac3babe13eca95a2b8e2cd963a896e

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

require 'active_record'

module Web
  class Portlet < ActiveRecord::Base

    @@caterpillar_portlets = nil

    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

    def self.find_caterpillar_portlet(name)
      self.caterpillar_portlets.select{
        |p| p.name=='%s' % name }.first # find_by_name
    end

    def title
      p = Web::PortletName.find_by_portletid(self.portletid)
      p ? p.title : nil
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caterpillar-0.9.8 lib/web/portlet.rb