Sha256: 379ac3b308f7d3494f2a45c44406b06cb0a69a0ebc589163ebd6a63dca6bd238

Contents?: true

Size: 645 Bytes

Versions: 4

Compression:

Stored size: 645 Bytes

Contents

module Vapid
  # Loads/fetches directives
  module Directives
    class << self
      attr_accessor :_registered

      def registered
        @_registered ||= {}
      end

      def content_changers
        registered.select { |_name, klass| klass.modifies_content? }
      end

      def [](name)
        # TODO: Fallback to text or raise exception?
        registered[name.to_s]
      end

      def register(name, klass)
        registered[name.to_s] = klass unless registered.key?(name)
      end
    end

    # Load Directives
    Dir[File.join(File.dirname(__FILE__), "directives/*")].each do |file|
      require file
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vapid-0.1.3 lib/vapid/directives.rb
vapid-0.1.2 lib/vapid/directives.rb
vapid-0.1.1 lib/vapid/directives.rb
vapid-0.1.0 lib/vapid/directives.rb