Sha256: 203e5f2d5360de1e78f7e12f2bd7cda86fb8171af25cf4b9fc9a22f22d034fe6

Contents?: true

Size: 697 Bytes

Versions: 7

Compression:

Stored size: 697 Bytes

Contents

module Dox
  module DSL
    module Syntax
      extend ActiveSupport::Concern

      def document(subject, &block)
        documentation = _subjects[subject] = Documentation.new(subject: subject)
        documentation.instance_eval(&block)
      end

      def const_missing(name)
        documentation = _subjects[infer_subject(name)]
        return super unless documentation

        Module.new do
          define_singleton_method :included do |base|
            base.metadata.merge! documentation.config
          end
        end
      end

      def infer_subject(name)
        name.to_s.underscore.to_sym
      end

      def _subjects
        @_subjects ||= {}
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dox-1.3.0 lib/dox/dsl/syntax.rb
dox-1.2.0 lib/dox/dsl/syntax.rb
dox-1.1.0 lib/dox/dsl/syntax.rb
dox-1.0.2 lib/dox/dsl/syntax.rb
dox-1.0.1 lib/dox/dsl/syntax.rb
dox-1.0.0 lib/dox/dsl/syntax.rb
dox-1.0.0.alpha lib/dox/dsl/syntax.rb