module Treequel::AttributeDeclarations

A collection of attribute declaration functions

Public Instance Methods

predicate_attr( *symbols ) click to toggle source

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

# File lib/treequel/mixins.rb, line 352
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