Class: RecordLoader::Adapter::Basic

Inherits:
Object
  • Object
show all
Defined in:
lib/record_loader/adapter/basic.rb

Overview

A very basic RecordLoader::Adapter which provides limited logging functionality, environment is extracted from RACK_ENV

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger: Logger.new(STDOUT)) ⇒ Basic

Create a new RecordLoader::Adapter::Basic. Can pass in a pre-existing logger is required.

Parameters:

  • logger (#debug&#info&#warn#&error&#fatal) (defaults to: Logger.new(STDOUT))

    Optional logger object. Creates a new ruby Logger by default.

See Also:


22
23
24
# File 'lib/record_loader/adapter/basic.rb', line 22

def initialize(logger: Logger.new(STDOUT))
  @logger = logger
end

Instance Attribute Details

#loggerLogger (readonly)

Returns The configured logger instance.

Returns:

  • (Logger)

    The configured logger instance


13
14
15
# File 'lib/record_loader/adapter/basic.rb', line 13

def logger
  @logger
end

Instance Method Details

#development?Boolean

Returns whether we are running in a development environment Determined by looking at RACK_ENV

Returns:

  • (Boolean)

    True if in development


43
44
45
# File 'lib/record_loader/adapter/basic.rb', line 43

def development?
  ENV.fetch('RACK_ENV', 'unknown').casecmp?('development')
end

#transactionVoid

Impliments the RecordLoader::Adapter interface by providing a transaction method. Used by Base.create!. This implimentation yields immediately, but otherwise performs no other functions.

Returns:

  • (Void)

33
34
35
# File 'lib/record_loader/adapter/basic.rb', line 33

def transaction
  yield
end