class Invitation::Configuration

Configure the invitation module. Invoke from a rails initializer.

Example:

Invitation.configure do |config|
  config.user_registration_path = ->(params) { new_profile_path(param) }
end

Attributes

case_sensitive_email[RW]

Enable or disable email case-sensivity when inviting users. If set to 'false', searching for user existence via email will disregard case.

Defaults to 'true'.

@return [Boolean]

mailer_sender[RW]

Controls the 'from' address for Invitation emails. Set this to a value appropriate to your application.

Defaults to reply@example.com.

@return [String]

routes[RW]

Enable or disable Invitation's built-in routes.

Defaults to 'true'.

If you disable the routes, your application is responsible for all routes.

You can deploy a copy of Invitations's routes with `rails generate invitation:routes`, which will also set `config.routes = false`.

@return [Boolean]

user_model[RW]

Name of the ActiveRecord class that represents users in your application.

Example:

Invitation.configure do |config|
  config.user_model = 'User'
end

DEPRECATED: can be set to the user class (not it's name), e.g. `config.user_model = User`. Support for setting the class directly may be removed in a future update.

Defaults to '::User'.

@return [ActiveRecord::Base]

user_registration_url[RW]

Url for new users to register for your application. New users are invited to sign up at this url via email. The url should be expressed as a lambda that accepts one argument, a params hash. This hash will contain the invitation token.

Defaults to: ->(params) { Rails.application.routes.url_helpers.sign_up_url(params) }

Note that the default assumes you have `sign_up_url`.

@return [Lambda]

Public Class Methods

new() click to toggle source
# File lib/invitation/configuration.rb, line 65
def initialize
  @user_model = '::User' #if defined?(::User)
  @user_registration_url = ->(params) { Rails.application.routes.url_helpers.sign_up_url(params) }
  @mailer_sender = 'reply@example.com'
  @routes = true
  @case_sensitive_email = true
end

Public Instance Methods

routes_enabled?() click to toggle source

@return [Boolean] are Invitation's built-in routes enabled?

# File lib/invitation/configuration.rb, line 106
def routes_enabled?
  @routes
end
user_model_class_name() click to toggle source
# File lib/invitation/configuration.rb, line 97
def user_model_class_name
  user_model.name.to_s
end
user_model_instance_var() click to toggle source
# File lib/invitation/configuration.rb, line 101
def user_model_instance_var
  '@' + user_model.name.demodulize.underscore
end