module FlashMessages

Private Instance Methods

clear_flash_messages() click to toggle source
# File lib/generators/flash_me/templates/flash_me_concern.rb, line 70
def clear_flash_messages
  flash.clear
end
flash_action_name() click to toggle source
# File lib/generators/flash_me/templates/flash_me_concern.rb, line 87
def flash_action_name
  ['destroy', 'publish'].include?(action_name) ? action_name + "ed" : action_name + "d"
end
flash_alert() click to toggle source

CRUD =======================================================================

# File lib/generators/flash_me/templates/flash_me_concern.rb, line 50
def flash_alert
  {
    clear: true,
    text: "Failed to #{action_name} #{flash_object_name}.",
    type: "alert"
  }
end
flash_everything_up_to_date() click to toggle source

Bulk Data Requests =========================================================

# File lib/generators/flash_me/templates/flash_me_concern.rb, line 14
def flash_everything_up_to_date
  {
    text: "Everything is up to date.",
    type: "success"
  }
end
flash_fetch_data_failed() click to toggle source
# File lib/generators/flash_me/templates/flash_me_concern.rb, line 28
def flash_fetch_data_failed
  {
    text: "Failed to fetch data requested!!",
    type: "alert"
  }
end
flash_fetch_data_success() click to toggle source
# File lib/generators/flash_me/templates/flash_me_concern.rb, line 21
def flash_fetch_data_success
  {
    text: "Successfully fetched data requested.",
    type: "success"
  }
end
flash_message(*messages) click to toggle source
# File lib/generators/flash_me/templates/flash_me_concern.rb, line 74
def flash_message(*messages)
  messages.each do |message|

    message_params = send("flash_#{message}".to_sym)

    clear = message_params[:clear]
    text  = message_params[:text]
    type  = message_params[:type].to_sym

    clear ? (flash.now[type] = text) : (flash[type] = text)
  end
end
flash_object_name() click to toggle source
# File lib/generators/flash_me/templates/flash_me_concern.rb, line 91
def flash_object_name
  controller_name.underscore.humanize.split.map {|word| word.singularize }.join(" ")
end
flash_success() click to toggle source
# File lib/generators/flash_me/templates/flash_me_concern.rb, line 58
def flash_success
  {
    clear: false,
    text: "#{flash_object_name} successfully #{flash_action_name}.",
    type: "success"
  }
end
flash_update_data_failed() click to toggle source
# File lib/generators/flash_me/templates/flash_me_concern.rb, line 42
def flash_update_data_failed
  {
    text: "Failed to update the requested data!!",
    type: "alert"
  }
end
flash_update_data_success() click to toggle source
# File lib/generators/flash_me/templates/flash_me_concern.rb, line 35
def flash_update_data_success
  {
    text: "Successfully updated the data requested.",
    type: "success"
  }
end
flash_user_not_found() click to toggle source

Authorizations =============================================================

# File lib/generators/flash_me/templates/flash_me_concern.rb, line 6
def flash_user_not_found
  {
    text: "No user was found matching the provided data.",
    type: "alert"
  }
end