Sha256: 877adcd1c7413ff124708f5692a43666f26315d5cf9f860b587375492460beaa

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 KB

Contents

module Adminpanel
    module RouterHelper
        def adminpanel_resources
            @files ||= find_resources
        end

        def find_resources
            resources_path
            if File.directory?(resources_path)
                files = Dir.entries(resources_path).collect do |f|
                    unless default_controllers.include?(f)
                        file_path = "#{resources_path}#{f}"
                        File.file?(file_path) ? file_path.sub!(resources_path, '').sub!('_controller.rb', '') : nil
                    end
                end

                files.compact!
            end
        end

        def menu_items
            @menu ||= adminpanel_resources.each.collect { |resource| resource.classify }
        end

        def default_controllers
            ["application_controller.rb", "sessions_controller.rb", "galleries_controller.rb", "users_controller.rb", "sections_controller.rb", "pages_controller.rb"]
        end

        def resources_path
            "#{Rails.root.to_s}/app/controllers/adminpanel/"
        end
    end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
adminpanel-1.2.4 app/helpers/adminpanel/router_helper.rb
adminpanel-1.2.3 app/helpers/adminpanel/router_helper.rb
adminpanel-1.2.2 app/helpers/adminpanel/router_helper.rb
adminpanel-1.2.1 app/helpers/adminpanel/router_helper.rb
adminpanel-1.2.0 app/helpers/adminpanel/router_helper.rb
adminpanel-1.1.0 app/helpers/adminpanel/router_helper.rb