Sha256: 7301cb34ba4ca938ba16b46c05daa7d4438411975cadac0f6c291b02c7ce776d

Contents?: true

Size: 919 Bytes

Versions: 1

Compression:

Stored size: 919 Bytes

Contents

#
# Blogaze
# Copyright (C) 2011-2013 Jack Polgar
#
# Blogaze is released under the BSD 3-clause license.
# @license http://opensource.org/licenses/BSD-3-Clause
#

module Blogaze
  class Theme
    attr_accessor :name
    attr_accessor :templates

    REGISTERED = {}

    def name=(name)
      @name = name.to_sym
    end

    class << self
      attr_accessor :current

      def add
        theme = self.new
        yield theme
        REGISTERED[theme.name] = theme
      end

      def [](name)
        name = name.to_sym
        raise("Invalid theme #{name}") unless REGISTERED.key?(name)
        return REGISTERED[name]
      end

      def use(name)
        name = name.to_sym
        raise("Unable to use theme #{name}: not registered") unless REGISTERED.key?(name)
        @current = REGISTERED[name]
      end

      def registered
        REGISTERED.to_a
      end
    end # Self
  end # Theme
end # Blogaze

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blogaze-0.0.1 lib/blogaze/theme.rb