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



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

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

.included(base) ⇒ Object

Since:

  • 4.0.0



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

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

.is_destination?Boolean

Returns true.

Returns:

  • (Boolean)

    true

Since:

  • 4.0.0



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

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



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

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

Instance Method Details

#ensure_dirObject

Since:

  • 4.0.0



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

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