def link(text = nil, options = {})
      #return self.tap{|a| a.extend AnnotatedArray}.collect{|e| e.link(text, options) } if Array === self
      return self.collect{|e| e.nil? ? nil : e.link(text, options) } if Array === self
      return self.split(";").collect{|e| self.annotate(e).link(text, options) } * ", " if self.include? ";"
      return nil if self.empty?

      klasses = self.klasses
      klasses <<  'entity'

      attributes, link_params = process_link_options(options)

      attributes[:class] << klasses
      attributes[:href] = Entity::REST.entity_url(self, entity_type.to_s, link_params)
      attributes["attr-entity_id"] = self.to_s

      attributes["data-entity-type"] = self.base_type
      attributes["data-entity"] = self.to_s
      attributes["data-entity-id"] = self.respond_to?(:default)? self.default || self.to_s : self.to_s

      begin
        text = self.respond_to?(:name)? self.name || self : self if text.nil?
      rescue
        text = self
      end
      attributes[:title] = text if attributes[:title].nil?

      Misc.html_tag('a', text, attributes)
    end
def link(text = nil, options = {})
      #return self.tap{|a| a.extend AnnotatedArray}.collect{|e| e.link(text, options) } if Array === self
      return self.collect{|e| e.nil? ? nil : e.link(text, options) } if Array === self
      return self.split(";").collect{|e| self.annotate(e).link(text, options) } * ", " if self.include? ";"
      return nil if self.empty?

      klasses = self.klasses
      klasses <<  'entity'

      attributes, link_params = process_link_options(options)

      attributes[:class] << klasses
      attributes[:href] = Entity::REST.entity_url(self, entity_type.to_s, link_params)
      attributes["attr-entity_id"] = self.to_s

      attributes["data-entity-type"] = self.base_type
      attributes["data-entity"] = self.to_s
      attributes["data-entity-id"] = self.respond_to?(:default)? self.default || self.to_s : self.to_s

      begin
        text = self.respond_to?(:name)? self.name || self : self if text.nil?
      rescue
        text = self
      end
      attributes[:title] = text if attributes[:title].nil?

      Misc.html_tag('a', text, attributes)
    end
{{{ LINKS