Sha256: cd93f77b71c69d243b5fd7da432d7513f5682e974d7d6f48bec52ab0ac29394f

Contents?: true

Size: 847 Bytes

Versions: 6

Compression:

Stored size: 847 Bytes

Contents

module Refinery
  module Pages

    def self.tabs
      @tabs ||= []
    end

    def self.tabs_for_template(template)
      return tabs unless template

      tabs.select do |tab|
        tab.templates.include?('all') || tab.templates.include?(template)
      end
    end

    class Tab
      attr_accessor :name, :partial, :templates

      def self.register(&block)
        tab = self.new

        yield tab

        raise "A tab MUST have a name!: #{tab.inspect}" if tab.name.blank?
        raise "A tab MUST have a partial!: #{tab.inspect}" if tab.partial.blank?

        tab.templates = %w[all] if tab.templates.blank?
        tab.templates = Array(tab.templates)

        tab
      end

    protected

      def initialize
        Refinery::Pages.tabs << self # add me to the collection of registered page tabs
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
refinerycms-pages-2.1.5 lib/refinery/pages/tab.rb
refinerycms-pages-2.1.4 lib/refinery/pages/tab.rb
refinerycms-pages-2.1.3 lib/refinery/pages/tab.rb
refinerycms-pages-2.1.2 lib/refinery/pages/tab.rb
refinerycms-pages-2.1.1 lib/refinery/pages/tab.rb
refinerycms-pages-2.1.0 lib/refinery/pages/tab.rb