Module: Kiba::Extend::Destinations::Destinationable

Included in:
CSV, JsonArray, Lambda, Marc
Defined in:
lib/kiba/extend/destinations/destinationable.rb

Overview

Mix-in module for extending destinations so they can be set up in jobs

Since:

  • 4.0.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.as_source_classObject

Returns:

  • Constant if there is a Sources class for reading the output of jobs that have this class as their destination

  • Nil if results of a job with this destination cannot be used as a source for another job

Raises:

  • (NotImplementedError)

Since:

  • 4.0.0



23
24
25
26
# File 'lib/kiba/extend/destinations/destinationable.rb', line 23

def self.as_source_class
  raise NotImplementedError,
    ":as_source_class must be defined in extending class"
end

.included(base) ⇒ Object

Since:

  • 4.0.0



14
15
16
# File 'lib/kiba/extend/destinations/destinationable.rb', line 14

def self.included(base)
  base.extend(Kiba::Extend::Registry::Fileable)
end

.is_destination?Boolean

Returns true.

Returns:

  • (Boolean)

    true

Since:

  • 4.0.0



29
# File 'lib/kiba/extend/destinations/destinationable.rb', line 29

def self.is_destination? = true

.special_optionsObject

Returns Array of defined special options for class.

Returns:

  • Array of defined special options for class

Raises:

  • (NotImplementedError)

Since:

  • 4.0.0



32
33
34
35
# File 'lib/kiba/extend/destinations/destinationable.rb', line 32

def self.special_options
  raise NotImplementedError,
    ":special_options must be defined in extending class"
end

Instance Method Details

#ensure_dirObject

Since:

  • 4.0.0



37
38
39
40
41
42
43
44
# File 'lib/kiba/extend/destinations/destinationable.rb', line 37

def ensure_dir
  return unless self.class.requires_path?

  dir = Pathname.new(send(self.class.path_key)).dirname
  return if Dir.exist?(dir)

  FileUtils.mkdir_p(dir)
end