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, Hash)

    file key from FileRegistry data hash. Alternately, a Hash containing jobkey: jobkey symbol, and additional key-value pairs may be passed.

  • 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
37
38
39
40
41
42
# File 'lib/kiba/extend/registry/registered_lookup.rb', line 23

def initialize(key:, data:, for_job:)
  super
  if key.is_a?(Hash)
    @key = key[:jobkey]
    @lookup_on = key[:lookup_on] if key.key?(:lookup_on)
    @instance_variable_name = key[:name] if key.key?(:name)
  end

  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



46
47
48
# File 'lib/kiba/extend/registry/registered_lookup.rb', line 46

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

#klassObject

Since:

  • 2.2.0



50
51
52
# File 'lib/kiba/extend/registry/registered_lookup.rb', line 50

def klass
  src_class
end