Treequel::

AttributeDeclarations

module

A collection of attribute declaration functions

Public Instance Methods

anchor
predicate_attr( *symbols )

Declare predicate accessors for the attributes associated with the specified symbols.

# File lib/treequel/mixins.rb, line 298
def predicate_attr( *symbols )
        symbols.each do |attrname|
                define_method( "#{attrname}?" ) do
                        instance_variable_defined?( "@#{attrname}" ) &&
                                instance_variable_get( "@#{attrname}" ) ? true : false
                end
                define_method( "#{attrname}=" ) do |newval|
                        instance_variable_set( "@#{attrname}", newval ? true : false )
                end
                alias_method "is_#{attrname}?", "#{attrname}?"
        end
end