aboutsummaryrefslogtreecommitdiffstats
path: root/lib/refinery/blog/tabs.rb
blob: 083d50bc19269a3aa5f25be3910ad6c7413694f3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Refinery
  module Blog
    attr_accessor :tabs

    def self.tabs
      @tabs ||= []
    end
    
    class Tab
      attr_accessor :name, :partial

      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?
      end

    protected

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