Module: Biovision::Components::Base::EntityLinks
- Included in:
- Biovision::Components::BaseComponent
- Defined in:
- app/lib/biovision/components/base/entity_links.rb
Overview
Links for entities in context of current user
Instance Method Summary collapse
- #entity_link(entity, scope = '') ⇒ Object
- #rest_entity_link(entity, scope) ⇒ Object
- #text_for_link(entity) ⇒ Object
Instance Method Details
#entity_link(entity, scope = '') ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/lib/biovision/components/base/entity_links.rb', line 15 def entity_link(entity, scope = '') prefix = i[admin my].include?(scope.to_sym) ? scope : 'world' = "#{prefix}_url".to_sym if entity.respond_to?() entity.send() else rest_entity_link(entity, scope.to_sym) end end |
#rest_entity_link(entity, scope) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/lib/biovision/components/base/entity_links.rb', line 27 def rest_entity_link(entity, scope) collection = "/#{scope}/#{entity.class.table_name}".gsub('//', '/') if entity.attributes.key?('uuid') && scope != :admin "#{collection}/#{entity.uuid}" else "#{collection}/#{entity.id}" end end |
#text_for_link(entity) ⇒ Object
9 10 11 |
# File 'app/lib/biovision/components/base/entity_links.rb', line 9 def text_for_link(entity) entity.respond_to?(:text_for_link) ? entity.text_for_link : entity.id end |