Sha256: 5f9f60d123bec860238e58e3fec3b79c7b8e2ab6d9ead514a7d306e08927aa6c

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

# Variable Annotations

Create a class that uses the `Annotative::Variables` mixin.

    class X
      extend Anise::Annotative::Variables

      variable_annotator :@doc

      @doc = "See what I mean?"

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

See that it is set.
  
    X.ann(:see, :@doc).should == "See what I mean?"

Variable annotations can override the standard annotation procedure with a
custom procedure.

    class Y
      extend Anise::Annotative::Variables

      def self.list
        @list ||= []
      end

      variable_annotator :@doc do |method, value|
        list << [method, value]
      end

      @doc = "See here!"

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

See that it is set.
  
    Y.list #=> [[:see, "See here!"]]

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
anise-0.7.0 demo/05_variables.md