Module: ResourceLinksHelper
- Defined in:
- app/helpers/resource_links_helper.rb
Overview
Utilities for building ResourceLink views
Constant Summary collapse
- SELF_ID =
' (self)'.freeze
Instance Method Summary collapse
-
#object_resource_choices_for(resources, subject_resource) ⇒ Array<Integer, String>
A collection of linkable objects for use with ResourceLink forms.
-
#predicate_for(resource_link) ⇒ String
A subject-verb-object predicate that describes the resource link.
Instance Method Details
#object_resource_choices_for(resources, subject_resource) ⇒ Array<Integer, String>
Returns a collection of linkable objects for use with ResourceLink forms
7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/resource_links_helper.rb', line 7 def object_resource_choices_for(resources, subject_resource) resources.map do |resource| option_name = if resource == subject_resource "#{resource.title} #{SELF_ID}" else resource.label end [option_name, resource.id] end end |
#predicate_for(resource_link) ⇒ String
Returns a subject-verb-object predicate that describes the resource link
20 21 22 |
# File 'app/helpers/resource_links_helper.rb', line 20 def predicate_for(resource_link) "#{sanitize(resource_link.subject_resource_title)} #{content_tag(:em, resource_link.verb)} #{sanitize(resource_link.object_resource_title)}".html_safe end |