Module: Fishplate

Defined in:
lib/fishplate.rb,
lib/fishplate/rack.rb,
lib/fishplate/version.rb,
lib/fishplate/sidekiq_middleware.rb

Defined Under Namespace

Classes: Rack, SidekiqMiddleware

Constant Summary collapse

VERSION =
"8.0.0".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject



46
47
48
# File 'lib/fishplate.rb', line 46

def logger
  @logger ||= ::Logger.new($stdout)
end

Class Method Details

.database_configurationObject



25
26
27
28
29
30
31
32
33
34
# File 'lib/fishplate.rb', line 25

def database_configuration
  @database_configuration ||= begin
    content = ERB.new(A9n.root.join('config/database.yml').read).result
    if RUBY_VERSION >= '3.1'
      YAML.load(content, aliases: true)
    else
      YAML.load(content)
    end
  end
end

.load_seedObject



13
14
15
16
17
# File 'lib/fishplate.rb', line 13

def load_seed
  return unless A9n.root.join('db/seeds.rb').exist?

  Kernel.load A9n.root.join('db/seeds.rb')
end

.load_tasksObject



19
20
21
22
23
# File 'lib/fishplate.rb', line 19

def load_tasks
  Kernel.load 'active_record/railties/databases.rake'
  Kernel.load File.expand_path('fishplate/tasks.rake', __dir__)
  A9n.root.join('lib/tasks').glob('**/*.rake').sort.each { |f| Kernel.load f }
end

.setup!Object



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fishplate.rb', line 50

def setup!
  configure_active_record

  setup_database_tasks

  setup_db_connection

  load_initializers

  add_i18n_load_paths if defined?(I18n)

  add_sidekiq_middleware if defined?(Sidekiq)
end

.time_zone=(value) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/fishplate.rb', line 36

def time_zone=(value)
  TZInfo::DataSource.get
  Time.find_zone!(value).tap do |zone|
    Time.zone = zone
    Time.zone_default = zone
  end
end