Sha256: 610004d412d4bc39b850ac5bb56def2b72c4f26ef6cb5b3d4721c1fd88af9568

Contents?: true

Size: 1.39 KB

Versions: 75

Compression:

Stored size: 1.39 KB

Contents

# -*- coding: utf-8 -*-
#
#--
# Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#

module Kramdown
  module Utils

    # Methods for registering configurable extensions.
    module Configurable

      # Create a new configurable extension called +name+.
      #
      # Three methods will be defined on the calling object which allow to use this configurable
      # extension:
      #
      # configurables:: Returns a hash of hashes that is used to store all configurables of the
      #                 object.
      #
      # <name>(ext_name):: Return the configured extension +ext_name+.
      #
      # add_<name>(ext_name, data=nil, &block):: Define an extension +ext_name+ by specifying either
      #                                          the data as argument or by using a block.
      def configurable(name)
        singleton_class = (class << self; self; end)
        singleton_class.send(:define_method, :configurables) do
          @_configurables ||= Hash.new {|h, k| h[k] = {}}
        end unless respond_to?(:configurables)
        singleton_class.send(:define_method, name) do |data|
          configurables[name][data]
        end
        singleton_class.send(:define_method, "add_#{name}".intern) do |data, *args, &block|
          configurables[name][data] = args.first || block
        end
      end

    end

  end
end

Version data entries

75 entries across 72 versions & 18 rubygems

Version Path
logstash-output-scalyr-0.2.1.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.2.0 vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.2.0.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.26.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.25.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.24.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.23.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.22.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.21.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.20.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.19.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.18.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.17.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.16.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.15.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.14.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.13 vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.12 vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.11.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb
logstash-output-scalyr-0.1.10.beta vendor/bundle/jruby/2.5.0/gems/kramdown-1.14.0/lib/kramdown/utils/configurable.rb