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.
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.
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!).