Sha256: d8c103374a32c2de3cf561be90281375b06883a25f2ca8d338906742de4c54ce

Contents?: true

Size: 1.11 KB

Versions: 14

Compression:

Stored size: 1.11 KB

Contents

# -*- encoding : utf-8 -*-

# card config overrides application.rb config overrides default
def load_recaptcha_config setting
  setting = "recaptcha_#{setting}".to_sym
  Cardio.config.send(
    "#{setting}=", load_recaptcha_card_config(setting) || # card content
                   Cardio.config.send(setting) || # application.rb
                   default_setting(setting)
  )
end

def default_setting setting
  Card::Auth::Permissions::RECAPTCHA_DEFAULTS[setting]
end

def card_table_ready?
  # FIXME: this test should be more generally usable
  ActiveRecord::Base.connection.table_exists?("cards") &&
    Card.ancestors.include?(ActiveRecord::Base)
end

# use if card with value is present
def load_recaptcha_card_config setting
  card = Card.find_by_codename setting
  card && card.db_content.present? && card.db_content
end

Recaptcha.configure do |config|
  # the seed task runs initializers so we have to check
  # if the cards table is ready before we use it here
  if card_table_ready?
    [:public_key, :private_key, :proxy].each do |setting|
      config.send "#{setting}=", load_recaptcha_config(setting)
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
card-1.91 config/initializers/recaptcha.rb
card-1.21.0 config/initializers/recaptcha.rb
card-1.20.4 config/initializers/recaptcha.rb
card-1.20.3 config/initializers/recaptcha.rb
card-1.20.2 config/initializers/recaptcha.rb
card-1.20.1 config/initializers/recaptcha.rb
card-1.20.0 config/initializers/recaptcha.rb
card-1.19.6 config/initializers/recaptcha.rb
card-1.19.5 config/initializers/recaptcha.rb
card-1.19.4 config/initializers/recaptcha.rb
card-1.19.3 config/initializers/recaptcha.rb
card-1.19.2 config/initializers/recaptcha.rb
card-1.19.1 config/initializers/recaptcha.rb
card-1.19.0 config/initializers/recaptcha.rb