class NotifyWith::InstallGenerator

Public Class Methods

next_migration_number(path) click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 5
def self.next_migration_number path
  unless @prev_migration_nr
  @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
  else
  @prev_migration_nr += 1
  end
  @prev_migration_nr.to_s
end

Public Instance Methods

add_notifications_route() click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 39
  def add_notifications_route
    route \
<<-CODE
namespace :api, defaults: { format: :json } do
    resources :notifications, only: [:index, :show, :update] do
      match :update_all, path: '/', via: [:put, :patch], on: :collection
    end
  end
CODE
  end
add_subject_locale() click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 54
  def add_subject_locale
    append_file "config/locales/#{I18n.locale.to_s}.yml" do
<<-CODE
  notifications_mailer:
    send_mail_by:
CODE
    end
  end
copy_api_notifications_controller() click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 30
def copy_api_notifications_controller
  template "notifications_controller.rb", "app/controllers/api/notifications_controller.rb"
end
copy_api_notifications_views() click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 34
def copy_api_notifications_views
  template "index.json.jbuilder", "app/views/api/notifications/index.json.jbuilder"
  template "show.json.jbuilder", "app/views/api/notifications/show.json.jbuilder"
end
copy_initializer() click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 50
def copy_initializer
  template "notify_with.rb", "config/initializers/notify_with.rb"
end
copy_notification_migration() click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 14
def copy_notification_migration
  migration_template "create_notification.rb", "db/migrate/create_notification.rb"
end
copy_notification_model() click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 18
def copy_notification_model
  template "notification.rb", "app/models/notification.rb"
end
copy_notification_type_model() click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 22
def copy_notification_type_model
  template "notification_type.rb", "app/models/notification_type.rb"
end
copy_notifications_mailer() click to toggle source
# File lib/generators/notify_with/install/install_generator.rb, line 26
def copy_notifications_mailer
  template "notifications_mailer.rb", "app/mailers/notifications_mailer.rb"
end