Class: Kiba::Extend::Registry::RegisteredLookup

Inherits:
RegisteredFile show all
Includes:
RequirableFile
Defined in:
lib/kiba/extend/registry/registered_lookup.rb

Overview

Value object representing a file registered in a FileRegistry that is being called into another job as a lookup table

Assumes this file will be used to build a Lookup

Since:

  • 2.2.0

Instance Attribute Summary

Attributes inherited from RegisteredFile

#data, #desc, #dest_class, #dest_opt, #dest_special_opts, #key, #lookup_on, #path, #src_opt, #supplied

Instance Method Summary collapse

Methods included from RequirableFile

#required

Methods inherited from RegisteredFile

#src_class

Constructor Details

#initialize(key:, data:, for_job:) ⇒ RegisteredLookup

Returns a new instance of RegisteredLookup.

Parameters:

  • key (Symbol)

    file key from FileRegistry data hash

  • data (Hash)

    file data from FileRegistry

  • for_job (Symbol)

    registry entry job key of the job for which this registered file is being prepared

Since:

  • 2.2.0



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/kiba/extend/registry/registered_lookup.rb', line 23

def initialize(key:, data:, for_job:)
  super
  unless src_class.respond_to?(:is_lookupable?)
    fail Kiba::Extend::JobCannotBeUsedAsLookupError.new(
      key, src_class, for_job
    )
  end
  unless lookup_on
    fail Kiba::Extend::NoLookupOnError.new(key, for_job)
  end
  unless lookup_on.is_a?(Symbol)
    fail Kiba::Extend::NonSymbolLookupOnError.new(key, for_job)
  end
end

Instance Method Details

#argsHash

Arguments for calling Lookup with this file

Returns:

  • (Hash)

Since:

  • 2.2.0



40
41
42
# File 'lib/kiba/extend/registry/registered_lookup.rb', line 40

def args
  {file: path, keycolumn: lookup_on}.merge(options)
end

#klassObject

Since:

  • 2.2.0



44
45
46
# File 'lib/kiba/extend/registry/registered_lookup.rb', line 44

def klass
  src_class
end