Module: Kiba::Extend::Transforms::SepDeprecatable
- 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
- Include in :initialize params:
sep: nil, delim: nil
- Include in class :initialize method:
@delim = usedelim(sepval: sep, delimval: delim, calledby: self)
Instance Method Summary collapse
Instance Method Details
#usedelim(sepval:, delimval:, calledby:, default: nil) ⇒ Object
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 |