Sha256: 997d628ae612535b6740af274875e633ee5401f2bd8a32bac9d36f5adf461b46

Contents?: true

Size: 1.45 KB

Versions: 29

Compression:

Stored size: 1.45 KB

Contents

module Cms
  module PathHelper
    def cms_index_path_for(resource, options={})
      send("cms_#{resource_collection_name(resource).pluralize}_path", options)
    end
    
    def cms_index_url_for(resource, options={})
      send("cms_#{resource_collection_name(resource).pluralize}_url", options)
    end
    
    def cms_new_path_for(resource, options={})
      send("new_cms_#{resource_collection_name(resource)}_path", options)
    end
    
    def cms_new_url_for(resource, options={})
      send("new_cms_#{resource_collection_name(resource)}_url", options)
    end
    
    def cms_connectable_path(connectable, options={})
      if Portlet === connectable
        cms_portlet_path(connectable)
      else
        [:cms, connectable]
      end
    end
    
    def edit_cms_connectable_path(connectable, options={})
      if Portlet === connectable
        edit_cms_portlet_path(connectable, options)
      else
        polymorphic_path([:edit, :cms, connectable], options)        
      end
    end
    
    private
      # Returns the name of the collection that this resouce belongs to
      # the resource can be a ContentType, ActiveRecord::Base instance
      # or just a string or symbol
      def resource_collection_name(resource)
        collection_name = case resource
          when ContentType then resource.name.underscore
          when ActiveRecord::Base then resource.class.name.underscore
          else resource.to_s
        end
      end
        
  end
end

Version data entries

29 entries across 29 versions & 9 rubygems

Version Path
SFEley-browsercms-3.0.2 app/helpers/cms/path_helper.rb
buzzware-browsercms-3.0.2 app/helpers/cms/path_helper.rb
coredumplings-browsercms-3.0.0 app/helpers/cms/path_helper.rb
we5-browsercms-3.0.1.1 app/helpers/cms/path_helper.rb
browsercms-3.1.5 app/helpers/cms/path_helper.rb
browsercms-3.1.4 app/helpers/cms/path_helper.rb
browsercms-3.1.3 app/helpers/cms/path_helper.rb
bf4-browsercms-3.1.0 app/helpers/cms/path_helper.rb
drujensen-browsercms-3.2.0 app/helpers/cms/path_helper.rb
browsercmsi-3.1.2 app/helpers/cms/path_helper.rb
browsercms-3.1.2 app/helpers/cms/path_helper.rb
browsercms-3.1.1 app/helpers/cms/path_helper.rb
browsercmsi-3.1.1 app/helpers/cms/path_helper.rb
browsercmsi-3.1.0 app/helpers/cms/path_helper.rb
browsercms-3.1.0 app/helpers/cms/path_helper.rb
we5-browsercms-3.1.0 app/helpers/cms/path_helper.rb
browsercms-3.0.6 app/helpers/cms/path_helper.rb
browsercms-3.0.5 app/helpers/cms/path_helper.rb
we5-browsercms-3.0.5.1 app/helpers/cms/path_helper.rb
we5-browsercms-3.0.5 app/helpers/cms/path_helper.rb