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

Constants

DEFAULT
DEPENDENCIES
VIEWS

Public Instance Methods

create_views() click to toggle source
# File lib/generators/rodauth/oauth/views_generator.rb, line 34
def create_views
  features = options[:all] ? VIEWS.keys : (%i[oauth_authorize] + options[:features]).map(&:to_sym).uniq

  views = features.inject([]) do |list, feature|
    list |= VIEWS[feature] || []
    list |= VIEWS[DEPENDENCIES[feature]] || []
  end

  directory = options[:directory].underscore
  views.each do |view|
    copy_file "app/views/rodauth/#{view}.html.erb",
             "app/views/#{directory}/#{view}.html.erb" do |content|
      content = content.gsub("rodauth/", "#{directory}/")
      content
    end
  end
end