class Kiqr::Generators::InstallGenerator

Public Instance Methods

add_kiqr_routes() click to toggle source
# File lib/generators/kiqr/install_generator.rb, line 38
def add_kiqr_routes
  route 'kiqr_routes'
end
copy_migrations() click to toggle source
# File lib/generators/kiqr/install_generator.rb, line 16
def copy_migrations
  unless model_exists?
    say "Couldn't find model #{class_name}"
    say 'Please install and configure Devise first.'
    return
  end

  migration_template 'accounts.rb', "#{migration_path}/create_accounts.rb"
  migration_template 'members.rb', "#{migration_path}/create_members.rb"
  migration_template 'add_account_id_to_users.rb', "#{migration_path}/add_account_id_to_#{table_name}.rb"
end
inject_user_model_content() click to toggle source
# File lib/generators/kiqr/install_generator.rb, line 28
def inject_user_model_content
  return unless model_exists?

  content = model_contents
  class_path = (namespaced? ? class_name.to_s.split('::') : [class_name])
  indent_depth = class_path.size - 1
  content = content.split("\n").map { |line| '  ' * indent_depth + line }.join("\n") << "\n"
  inject_into_class(model_path, class_path.last, content)
end

Private Instance Methods

model_contents() click to toggle source
# File lib/generators/kiqr/install_generator.rb, line 44
def model_contents
  '  include Kiqr::Models::User'
end