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