Class: Nemo::MetaObject::TextAttribute

Inherits:
Attribute
  • Object
show all
Defined in:
lib/nemo/metaobject/attributes.rb

Direct Known Subclasses

DateAttribute, PasswordAttribute

Instance Attribute Summary

Attributes inherited from Attribute

#metaobject, #symbol, #validation_rules

Instance Method Summary collapse

Methods inherited from Attribute

#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) ⇒ TextAttribute

Returns a new instance of TextAttribute.



81
82
83
84
85
# File 'lib/nemo/metaobject/attributes.rb', line 81

def initialize(symbol)
  super
  @maxlength = 255
  @multiline = false
end

Instance Method Details

#accept(visitor) ⇒ Object



87
88
89
# File 'lib/nemo/metaobject/attributes.rb', line 87

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

#add_required_ruleObject



91
92
93
# File 'lib/nemo/metaobject/attributes.rb', line 91

def add_required_rule
  add_validation_rule { |value| ! value.to_s.strip.empty? }.error_string('required')
end

#cacheObject



95
96
97
# File 'lib/nemo/metaobject/attributes.rb', line 95

def cache
  @cache.to_s
end