Sha256: ecdc3e639ac89ff4c5d73a740a53e169a16e69921d27ae8eccd3d162f20f7629

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

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

require "active_support/core_ext/numeric/time"
require "cardio/schema"
require "cardio/utils"
require "cardio/delaying"

ActiveSupport.on_load :after_card do
  Cardio::Mod.load
end

module Cardio
  extend Schema
  extend Utils
  extend Delaying
  CARD_GEM_ROOT = File.expand_path("..", __dir__)

  class << self
    delegate :application, :root, to: :Rails
    delegate :config, :paths, to: :application

    def gem_root
      CARD_GEM_ROOT
    end

    def card_defined?
      const_defined? "Card"
    end

    def load_card?
      ActiveRecord::Base.connection && !card_defined?
    rescue StandardError
      false
    end

    def load_card!
      require "card"
      ActiveSupport.run_load_hooks :after_card
    end

    def cache
      @cache ||= ::Rails.cache
    end

    def future_stamp
      # # used in test data
      @future_stamp ||= Time.zone.local 2020, 1, 1, 0, 0, 0
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
card-1.102.0 lib/cardio.rb