Module Anise::Annotative::Methods
In: lib/anise/annotative/methods.rb

The Annotator::Method module allows for the creation of annotations which attach to the next method defined.

This idiom of annotation-before-definition was popularized by Rake‘s `desc`/`task` pair. This module can be used to add similar capabilites to any class or module.

    class X
      extend Anise::Annotative::Methods

      def self.doc(string)
        method_annotation(:doc => string)
      end

      doc "See what I mean?"

      def see
        puts "Yes, I see!"
      end
    end

    X.ann(:see, :doc) #=> "See what I mean?"

One can get a bit more control over the creation of annotations by using a block. In this case it is up the code to actually create the annotation.

    def self.doc(string)
      method_annotation do |meth|
        ann meth, :doc => string
      end
    end

Note that the library uses the method_added callback, so be sure to respect good practices of calling super if you need to override this method.

Methods

Included Modules

Annotations

Public Class methods

This a temporary store used to create method annotations.

Public Instance methods

When a method is added, run all pending annotations.

@param [Symbol] sym

  The name of the method added.

Setup a pending method annotation.

@param [Hash] annotations

  The annotation settings.

Define a method annotation.

@example

  method_annotator :doc

@param name [Symbol]

  Name of annotation.

[Validate]