Module: Cardio

Extended by:
Delaying
Defined in:
card/lib/cardio.rb,
card/lib/cardio/job.rb,
card/lib/cardio/mod.rb,
card/lib/cardio/seed.rb,
card/lib/cardio/utils.rb,
card/lib/cardio/record.rb,
card/lib/cardio/schema.rb,
card/lib/cardio/mod/eat.rb,
card/lib/cardio/railtie.rb,
card/lib/cardio/version.rb,
card/lib/cardio/commands.rb,
card/lib/cardio/delaying.rb,
card/lib/cardio/mod/dirs.rb,
card/lib/cardio/mod/poop.rb,
card/lib/cardio/migration.rb,
card/lib/cardio/generators.rb,
card/lib/cardio/mod/loader.rb,
card/lib/cardio/script_loader.rb,
card/lib/cardio/migration/core.rb,
card/lib/cardio/commands/custom.rb,
card/lib/cardio/generators/base.rb,
card/lib/cardio/mod/eat/edibles.rb,
card/lib/cardio/mod/modfile_api.rb,
card/lib/cardio/commands/command.rb,
card/lib/cardio/migration/import.rb,
card/lib/cardio/mod/class_methods.rb,
card/lib/cardio/mod/load_strategy.rb,
card/lib/cardio/mod/modfile_loader.rb,
card/lib/cardio/generators/mod_base.rb,
card/lib/cardio/mod/module_template.rb,
card/lib/cardio/commands/rake_command.rb,
card/lib/cardio/mod/loader/set_loader.rb,
card/lib/generators/mod/mod_generator.rb,
card/lib/generators/set/set_generator.rb,
card/lib/cardio/commands/rspec_command.rb,
card/lib/cardio/generators/deck_helper.rb,
card/lib/cardio/mod/load_strategy/eval.rb,
card/lib/cardio/migration/import/merger.rb,
card/lib/cardio/mod/loader/set_template.rb,
card/lib/generators/deck/deck_generator.rb,
card/lib/cardio/migration/deck_structure.rb,
decko/lib/generators/deck/deck_generator.rb,
card/lib/cardio/generators/rails_overrides.rb,
card/lib/cardio/mod/load_strategy/tmp_files.rb,
card/lib/cardio/migration/import/import_data.rb,
card/lib/cardio/commands/rspec_command/parser.rb,
card/lib/cardio/mod/loader/set_pattern_loader.rb,
card/lib/cardio/mod/load_strategy/set_tmp_files.rb,
card/lib/generators/migration/migration_generator.rb,
card/lib/cardio/mod/load_strategy/pattern_tmp_files.rb,
card/lib/cardio/mod/load_strategy/set_binding_magic.rb,
card/lib/cardio/migration/import/import_data/card_content.rb,
card/lib/cardio/migration/import/import_data/card_attributes.rb

Defined Under Namespace

Modules: Delaying, Generators, Schema, ScriptLoader, Seed, Utils, Version Classes: Commands, Job, Migration, Mod, Railtie, Record

Constant Summary collapse

Application =

The application class from which card applications inherit

Rails::Application

Class Method Summary collapse

Methods included from Delaying

delaying!, delaying?

Class Method Details

.cacheObject



37
38
39
# File 'card/lib/cardio.rb', line 37

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

.card_defined?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'card/lib/cardio.rb', line 22

def card_defined?
  const_defined? "Card"
end

.databaseObject



41
42
43
# File 'card/lib/cardio.rb', line 41

def database
  @database ||= config.database_configuration.dig Rails.env, "database"
end

.gem_rootObject



18
19
20
# File 'card/lib/cardio.rb', line 18

def gem_root
  @gem_root ||= File.expand_path "..", __dir__
end

.load_card!Object



32
33
34
35
# File 'card/lib/cardio.rb', line 32

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

.load_card?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
# File 'card/lib/cardio.rb', line 26

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

.modsObject



45
46
47
# File 'card/lib/cardio.rb', line 45

def mods
  Mod.dirs.mods
end

.with_config(tmp) ⇒ Object



49
50
51
52
53
54
55
# File 'card/lib/cardio.rb', line 49

def with_config tmp
  keep = tmp.keys.each_with_object({}) { |k, h| h[k] = config.send k }
  tmp.each { |k, v| config.send "#{k}=", v }
  yield
ensure
  keep.each { |k, v| config.send "#{k}=", v }
end