Top Level Namespace

Defined Under Namespace

Modules: BaseHelper, BulletTrain, Colorizer, DeviseCurrentAttributes, DocumentationSupport, EmailHelper, InvitationOnlyHelper, Invitations, InvitationsHelper, InviteOnlySupport, Memberships, RootRedirect, Teams, Users Classes: Address, ApplicationController, ApplicationHash, ApplicationRecord, DeviseMailer, Invitation, Membership, RegistrationsController, RemovingLastTeamAdminException, RemovingLastTeamException, SessionsController, Team, User, UserMailer

Instance Method Summary collapse

Instance Method Details

#any_oauth_enabled?Boolean

Returns:

  • (Boolean)


161
162
163
164
165
166
# File 'lib/bullet_train.rb', line 161

def any_oauth_enabled?
  [
    stripe_enabled?,
    # 🚅 super scaffolding will insert new oauth provider checks above this line.
  ].select(&:present?).any?
end

#billing_enabled?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/bullet_train.rb', line 108

def billing_enabled?
  (ENV["STRIPE_SECRET_KEY"].present? || ENV["PADDLE_SECRET_KEY"].present?) && defined?(BulletTrain::Billing)
end

#billing_subscription_creation_disabled?Boolean

TODO This should be in an initializer or something.

Returns:

  • (Boolean)


113
114
115
# File 'lib/bullet_train.rb', line 113

def billing_subscription_creation_disabled?
  false
end

#bulk_invitations_enabled?Boolean

Returns:

  • (Boolean)


197
198
199
# File 'lib/bullet_train.rb', line 197

def bulk_invitations_enabled?
  BulletTrain::Configuration.enable_bulk_invitations
end

#cloudinary_enabled?Boolean

Returns:

  • (Boolean)


151
152
153
# File 'lib/bullet_train.rb', line 151

def cloudinary_enabled?
  ENV["CLOUDINARY_URL"].present?
end

#default_url_options_from_base_urlObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/bullet_train.rb', line 51

def default_url_options_from_base_url
  unless ENV["BASE_URL"].present?
    if Rails.env.development?
      ENV["BASE_URL"] = "http://localhost:3000"
    else
      return {}
    end
  end

  parsed_base_url = URI.parse(ENV["BASE_URL"])
  default_url_options = [:user, :password, :host, :port].map { |key| [key, parsed_base_url.send(key)] }.to_h

  # the name of this property doesn't match up.
  default_url_options[:protocol] = parsed_base_url.scheme
  default_url_options.compact!

  if default_url_options.empty?
    raise "ENV['BASE_URL'] has not been configured correctly. Please check your environment variables and try one more time."
  end

  default_url_options
end

#demo?Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/bullet_train.rb', line 147

def demo?
  ENV["DEMO"].present?
end

#disable_developer_menu?Boolean

Returns:

  • (Boolean)


201
202
203
# File 'lib/bullet_train.rb', line 201

def disable_developer_menu?
  ENV["DISABLE_DEVELOPER_MENU"].present?
end

#font_awesome?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/bullet_train.rb', line 177

def font_awesome?
  ENV["FONTAWESOME_NPM_AUTH_TOKEN"].present?
end

#free_trial?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/bullet_train.rb', line 117

def free_trial?
  ENV["STRIPE_FREE_TRIAL_LENGTH"].present?
end

#heroku?Boolean

Returns:

  • (Boolean)


74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/bullet_train.rb', line 74

def heroku?
  # This is a value we set in `app.json` so anyone using the "Deploy to Heroku" button
  # should have it. This is kind of a brute force method that should be future-proofed
  # against changes that Heroku might make to their runtime environment. We'll fallback
  # to some additional checks if this isn't here, to maintain backwards compatibility
  # for existing apps.
  if ENV["BT_IS_IN_HEROKU"].present?
    ENV["BT_IS_IN_HEROKU"] == "true"
  else
    # This requires the app to run `heroku labs:enable runtime-dyno-metadata` and then
    # deploy at least once before the ENV var is set. Many existing BT apps have enabled
    # this feature, and this used to be the only detection method that we had. We're
    # keeping it for backwards compability reasons because it's probably more stable
    # than the following fallbacks.
    ENV["HEROKU_APP_NAME"].present? ||
      # And finally we fallback to checking for some artifacts that Heroku happens to leave
      # lying around. These may change in the future, so who knows how long they'll be good.
      #
      # If there's a `DYNO` ENV var, then we're probably on Heroku. Will they _always_ set
      # this variable?
      ENV["DYNO"].present? ||
      # Finally we look for the the existence of the `/app/.heroku` directory.
      # This should make detection work for apps that don't have any of the above ENV vars, for
      # whatever reasons. But, in the future Heroku could decide to remove `/app/.heroku`
      # which will break this fallback method and then we'll have to come up with something else.
      # This is currently our last line of defense.
      File.directory?("/app/.heroku")
  end
end

#hide_examples?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/bullet_train.rb', line 135

def hide_examples?
  ActiveModel::Type::Boolean.new.cast(ENV["HIDE_EXAMPLES"])
end

#hide_things?Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/bullet_train.rb', line 131

def hide_things?
  ActiveModel::Type::Boolean.new.cast(ENV["HIDE_THINGS"])
end

#inbound_email_enabled?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/bullet_train.rb', line 104

def inbound_email_enabled?
  ENV["INBOUND_EMAIL_DOMAIN"].present?
end

#invitation_keysObject



173
174
175
# File 'lib/bullet_train.rb', line 173

def invitation_keys
  ENV["INVITATION_KEYS"].split(",").map(&:strip)
end

#invitation_only?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/bullet_train.rb', line 169

def invitation_only?
  ENV["INVITATION_KEYS"].present?
end

#multiple_locales?Boolean

Returns:

  • (Boolean)


181
182
183
# File 'lib/bullet_train.rb', line 181

def multiple_locales?
  @multiple_locales ||= I18n.available_locales.many?
end

#openai_enabled?Boolean

Returns:

  • (Boolean)


189
190
191
# File 'lib/bullet_train.rb', line 189

def openai_enabled?
  ENV["OPENAI_ACCESS_TOKEN"].present?
end

#openai_organization_exists?Boolean

Returns:

  • (Boolean)


193
194
195
# File 'lib/bullet_train.rb', line 193

def openai_organization_exists?
  ENV["OPENAI_ORGANIZATION_ID"]
end

#sample_role_disabled?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/bullet_train.rb', line 143

def sample_role_disabled?
  hide_examples?
end

#scaffolding_things_disabled?Boolean

Returns:

  • (Boolean)


139
140
141
# File 'lib/bullet_train.rb', line 139

def scaffolding_things_disabled?
  hide_things? || hide_examples?
end

#silence_logs?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'lib/bullet_train.rb', line 185

def silence_logs?
  ENV["SILENCE_LOGS"].present?
end

#stripe_enabled?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/bullet_train.rb', line 121

def stripe_enabled?
  ENV["STRIPE_CLIENT_ID"].present?
end

#two_factor_authentication_enabled?Boolean

Returns:

  • (Boolean)


155
156
157
# File 'lib/bullet_train.rb', line 155

def two_factor_authentication_enabled?
  Rails.application.credentials.active_record_encryption&.primary_key.present? || Rails.configuration&.active_record&.encryption&.primary_key.present?
end

#webhooks_enabled?Boolean

🚅 super scaffolding will insert new oauth providers above this line.

Returns:

  • (Boolean)


127
128
129
# File 'lib/bullet_train.rb', line 127

def webhooks_enabled?
  true
end