Class: Nemo::MetaObject::BooleanAttribute

Inherits:
RelationshipAttribute show all
Defined in:
lib/nemo/metaobject/attributes.rb

Instance Attribute Summary

Attributes inherited from Attribute

#cache, #metaobject, #symbol, #validation_rules

Instance Method Summary collapse

Methods inherited from RelationshipAttribute

#formatted_items, #items

Methods inherited from Attribute

#add_required_rule, #add_validation_rule, #commit_cache, #error_class, #format, #formatted_value, #refresh_cache, #required, #required?, #rule_class, #validate_cache, #value

Methods included from Util::Accessors

#bool_accessor, #call_accessor, #proc_accessor

Constructor Details

#initialize(symbol) ⇒ BooleanAttribute

Returns a new instance of BooleanAttribute.



219
220
221
222
223
224
225
# File 'lib/nemo/metaobject/attributes.rb', line 219

def initialize(symbol)
  super
  @true_item_string = 'yes'
  @false_item_string = 'no'
  @relationship_to = Proc.new { [true,false] }
  @format_with = Proc.new { |value| value ? @true_item_string : @false_item_string }
end

Instance Method Details

#accept(visitor) ⇒ Object



227
228
229
# File 'lib/nemo/metaobject/attributes.rb', line 227

def accept(visitor)
  visitor.visit_boolean_attribute(self)
end