class ActivityNotification::Generators::ViewsGenerator

View generator to copy customizable view files to rails application. Include this module in your generator to generate ActivityNotification views. `copy_views` is the main method and by default copies all views of ActivityNotification. @example Run view generator to create customizable default views for all targets

rails generate activity_notification:views

@example Run view generator to create views for users as the specified target

rails generate activity_notification:views users

@example Run view generator to create only notification views

rails generate activity_notification:views -v notifications

@example Run view generator to create only notification email views

rails generate activity_notification:views -v mailer

Constants

VIEWS

Public Instance Methods

copy_views() click to toggle source

Copies view files in application directory

# File lib/generators/activity_notification/views_generator.rb, line 29
def copy_views
  target_views = options[:views] || VIEWS
  target_views.each do |directory|
    view_directory directory.to_sym
  end
end

Protected Instance Methods

plural_target() click to toggle source

Gets plural_target from target argument or default value @api protected @return [String] target_path from target argument or default value

# File lib/generators/activity_notification/views_generator.rb, line 56
def plural_target
  @plural_target ||= target.presence && target.to_s.underscore.pluralize
end
target_path() click to toggle source

Gets target_path from an argument or default value @api protected @return [String] target_path from an argument or default value

# File lib/generators/activity_notification/views_generator.rb, line 49
def target_path
  @target_path ||= "app/views/activity_notification"
end
view_directory(name, view_target_path = nil) click to toggle source

Copies view files to target directory @api protected @param [String] name Set name of views (notifications or mailer) @param [String] view_target_path Target path to create views

# File lib/generators/activity_notification/views_generator.rb, line 42
def view_directory(name, view_target_path = nil)
  directory "#{name}/default", view_target_path || "#{target_path}/#{name}/#{plural_target || :default}"
end