Module Anise::Annotative::Attributes
In: lib/anise/annotative/attributes.rb

The {Annotative::Attributes} mixin modifies the attr_* methods to allow easy addition of annotations for attributes. It modifies the built in attribute methods (attr, attr_reader, attr_writer and attr_accessor), and any other custom `attr_*` methods, to allow annotations to be added to them directly rather than requiring a separate annotating statement.

  class X
    extend Anise::Annotative::Attributes

    attr :a, :valid => lambda{ |x| x.is_a?(Integer) }
  end

See {Annotation} module for more information.

@todo Currently annotated attributes alwasy use the standard

      annotator (:ann). In the future we might make this customizable.

Methods

Included Modules

Annotations

Public Class methods

Define an annotated attribute method, given an existing non-annotated attribute method.

When included into a class or module, {Annotation} is also included and {Attribute::Aid} extends the class/module.

@param base [Class, Module]

  The class or module to get features.

Public Instance methods

This defines a simple adjustment to attr to allow it to handle the boolean argument and to be able to accept attributes. It‘s backward compatible and is not needed for Ruby 1.9 which gets rid of the secondary argument (or was suppose to!).

Return list of attributes that have a :class annotation.

  class MyClass
    attr_accessor :test
    attr_accessor :name, String, :doc => 'Hello'
    attr_accessor :age, Fixnum
  end

  MyClass.instance_attributes # => [:test, :name, :age, :body]
  MyClass.classified_attributes # => [:name, :age]

Instance attributes, including inherited attributes.

Local instance attributes.

[Validate]