Class: Nemo::MetaObject::MultipleRelationshipAttribute
Instance Attribute Summary
Attributes inherited from Attribute
#cache, #metaobject, #symbol, #validation_rules
Instance Method Summary
collapse
#formatted_items, #items
Methods inherited from Attribute
#add_validation_rule, #commit_cache, #error_class, #format, #initialize, #required, #required?, #rule_class, #validate_cache, #value
#bool_accessor, #call_accessor, #proc_accessor
Instance Method Details
#accept(visitor) ⇒ Object
257
258
259
|
# File 'lib/nemo/metaobject/attributes.rb', line 257
def accept(visitor)
visitor.visit_multiple_relationship_attribute(self)
end
|
#add_required_rule ⇒ Object
261
262
263
|
# File 'lib/nemo/metaobject/attributes.rb', line 261
def add_required_rule
add_validation_rule { |value| ! value.to_s.empty? }.error_string('required')
end
|
#add_to_cache(item) ⇒ Object
265
266
267
268
|
# File 'lib/nemo/metaobject/attributes.rb', line 265
def add_to_cache(item)
@cache ||= Array.new
@cache << item
end
|
278
279
280
|
# File 'lib/nemo/metaobject/attributes.rb', line 278
def formatted_value
value.collect { |item| format(item) }
end
|
#refresh_cache ⇒ Object
270
271
272
|
# File 'lib/nemo/metaobject/attributes.rb', line 270
def refresh_cache
@cache = value.collect
end
|
#remove_from_cache(item) ⇒ Object
274
275
276
|
# File 'lib/nemo/metaobject/attributes.rb', line 274
def remove_from_cache(item)
cache.delete(item)
end
|