Module: Kiba::Extend::Transforms::SepDeprecatable

Included in:
CombineValues::FromFieldsWithDelimiter, Deduplicate::GroupedFieldValues
Defined in:
lib/kiba/extend/transforms/sep_deprecatable.rb

Overview

Mixin module to handle sep and delim params in Transforms classes that are deprecating the sep param in favor of delim, but haven’t removed sep yet.

Use/implementation

Classes deprecating sep should:

1.

include SepDeprecatable
  1. Include in :initialize params:
sep: nil, delim: nil
  1. Include in class :initialize method:
  @delim = usedelim(sepval: sep, delimval: delim, calledby: self)

Since:

  • 3.3.0

Instance Method Summary collapse

Instance Method Details

#usedelim(sepval:, delimval:, calledby:, default: nil) ⇒ Object

Parameters:

  • sepval (String)

    sep value passed to class

  • delimval (String)

    delim value passed to class

  • calledby

    Instance of the class in which sep is being deprecated

  • default (nil, String) (defaults to: nil)

    default sep/nil value used if none given

Since:

  • 3.3.0



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/kiba/extend/transforms/sep_deprecatable.rb', line 38

def usedelim(sepval:, delimval:, calledby:, default: nil)
  if delimval && !sepval
    delimval
  elsif !delimval && sepval
    warn("#{Kiba::Extend.warning_label}:\n"\
         "  #{calledby.class}: `sep` parameter will be "\
         "deprecated in a future release.\n"\
         "TO FIX:\n"\
         "  Change `sep` to `delim`")
    sepval
  elsif delimval && sepval
    warn("#{Kiba::Extend.warning_label}:\n"\
         "  #{calledby.class}: `sep` and `delim` parameters "\
         "given. `delim` value used. `sep` value ignored. "\
         "`sep` will be deprecated in a future release.\n"\
         "TO FIX:\n  Remove `sep` param")
    delimval
  else
    return default if default

    fail(ArgumentError, "#{calledby.class}: missing keyword: :delim")
  end
end