module DogBiscuitsHelper
Public Instance Methods
publication_status(value)
click to toggle source
Return the label for publication status
@param value [String] @return [String]
# File lib/generators/dog_biscuits/templates/app/helpers/dog_biscuits_helper.rb, line 7 def publication_status(value) if value.is_a? String publication_status_label(status) elsif value.is_a? Hash value[:value].map { |status| publication_status_label(status) } end end
publication_status_label(value)
click to toggle source
# File lib/generators/dog_biscuits/templates/app/helpers/dog_biscuits_helper.rb, line 15 def publication_status_label(value) service = AuthorityService::PublicationStatusesService.new service.label(value) rescue KeyError value end
restricted?(term)
click to toggle source
# File lib/generators/dog_biscuits/templates/app/helpers/dog_biscuits_helper.rb, line 35 def restricted?(term) return false if DogBiscuits.config.restricted_properties_enabled == false # evaluate restriction ( DogBiscuits.config.restricted_properties.include?(term) && current_user.send("#{DogBiscuits.config.restricted_role}?") == true ) || !DogBiscuits.config.restricted_properties.include?(term) end
truncate_text(text)
click to toggle source
# File lib/generators/dog_biscuits/templates/app/helpers/dog_biscuits_helper.rb, line 31 def truncate_text(text) text.truncate_words(50, omission: ' ...') end
truncate_text_and_iconify_link(value)
click to toggle source
# File lib/generators/dog_biscuits/templates/app/helpers/dog_biscuits_helper.rb, line 22 def truncate_text_and_iconify_link(value) if value.is_a? String iconify_auto_link(truncate_text(value).to_s) elsif value.is_a? Hash value[:value] = value[:value].map { |text| truncate_text(text).to_s } iconify_auto_link(value) end end