Sha256: e30f7056a564f0cfca8cb4468777e8dab91f3030ba6c8bda43deb5c310208e8e

Contents?: true

Size: 750 Bytes

Versions: 8

Compression:

Stored size: 750 Bytes

Contents

require 'hashie'
require 'pathname'

module RooOnRails
  class Config < Hashie::Mash
    class << self
      def load
        path = Pathname '.roo_on_rails.yml'
        path.exist? ? super(path) : new
      end

      def sidekiq_enabled?
        enabled? 'SIDEKIQ_ENABLED'
      end

      def google_auth_enabled?
        enabled? 'GOOGLE_AUTH_ENABLED', default: false
      end

      def google_auth_path_prefix
        ENV.fetch('GOOGLE_AUTH_PATH_PREFIX')
      end

      def google_auth_controller
        ENV.fetch('GOOGLE_AUTH_CONTROLLER')
      end

      private

      ENABLED_PATTERN = /\A(YES|TRUE|ON|1)\Z/i

      def enabled?(var, default: 'true')
        ENABLED_PATTERN === ENV.fetch(var, default).to_s
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
roo_on_rails-2.2.2 lib/roo_on_rails/config.rb
roo_on_rails-2.2.1 lib/roo_on_rails/config.rb
roo_on_rails-2.2.0 lib/roo_on_rails/config.rb
roo_on_rails-2.1.2 lib/roo_on_rails/config.rb
roo_on_rails-2.1.0 lib/roo_on_rails/config.rb
roo_on_rails-2.0.0.pre.pre.2 lib/roo_on_rails/config.rb
roo_on_rails-1.8.1 lib/roo_on_rails/config.rb
roo_on_rails-1.8.0 lib/roo_on_rails/config.rb