class Rodauth::OAuth::Rails::Generators::ViewsGenerator

  1. lib/generators/rodauth/oauth/views_generator.rb
Superclass: Rails::Generators::Base

Methods

Public Instance

  1. create_views

Constants

DEFAULT = %w[authorize].freeze  
DEPENDENCIES = { }.freeze  
VIEWS = { oauth_authorize: DEFAULT, oauth_applications: %w[oauth_applications oauth_application new_oauth_application] }.freeze  

Public Instance methods

create_views()
[show source]
   # File lib/generators/rodauth/oauth/views_generator.rb
34 def create_views
35   features = options[:all] ? VIEWS.keys : (%i[oauth_authorize] + options[:features]).map(&:to_sym).uniq
36 
37   views = features.inject([]) do |list, feature|
38     list |= VIEWS[feature] || []
39     list |= VIEWS[DEPENDENCIES[feature]] || []
40   end
41 
42   directory = options[:directory].underscore
43   views.each do |view|
44     copy_file "app/views/rodauth/#{view}.html.erb",
45              "app/views/#{directory}/#{view}.html.erb" do |content|
46       content = content.gsub("rodauth/", "#{directory}/")
47       content
48     end
49   end
50 end