Sha256: fc66fd0e4aed783a41c4a0d7758900194c7cd5b06b2b50847444b18e74c9250d

Contents?: true

Size: 768 Bytes

Versions: 2

Compression:

Stored size: 768 Bytes

Contents

module Dox
  module DSL
    module Syntax
      extend ActiveSupport::Concern

      class_methods do
        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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dox-0.0.3 lib/dox/dsl/syntax.rb
dox-0.0.2 lib/dox/dsl/syntax.rb