Module: Treequel::AttributeDeclarations
- Included in:
- Branch, Schema::AttributeType, Schema::LDAPSyntax, Schema::MatchingRule, Schema::MatchingRuleUse, Schema::ObjectClass
- Defined in:
- lib/treequel/mixins.rb
Overview
A collection of attribute declaration functions
Class Method Summary collapse
-
.predicate_attr(*symbols) ⇒ Object
Declare predicate accessors for the attributes associated with the specified
symbols.
Class Method Details
.predicate_attr(*symbols) ⇒ Object
Declare predicate accessors for the attributes associated with the specified symbols.
299 300 301 302 303 304 305 306 307 308 309 310 |
# File 'lib/treequel/mixins.rb', line 299 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 |