Skip to content
Snippets Groups Projects
Commit 01270b2f authored by Vladimir Davydov's avatar Vladimir Davydov Committed by Feodor Alexandrov
Browse files

compat: move is_new and is_old option methods to metatable

The is_new and is_old methods are the same for all compat options so
they should be defined in a metatable. A good thing about this change
is that it removes is_new and is_old from serialization:

* Before:

NO_WRAP
  tarantool> require('compat').yaml_pretty_multiline
  ---
  - is_new: 'function: 0x4175d6e8'
    is_old: 'function: 0x4175d790'
    brief: |
      Whether to encode in block scalar style all multiline strings or ones
      containing "\n\n" substring. The new behavior makes all multiline string output
      as single text block which is handier for the reader, but may be incompatible
      with some existing applications that rely on the old style.

      https://tarantool.io/compat/yaml_pretty_multiline
    current: default
    default: new
  ...
NO_WRAP

* After:

NO_WRAP
  tarantool> require('compat').yaml_pretty_multiline
  ---
  - current: default
    brief: |
      Whether to encode in block scalar style all multiline strings or ones
      containing "\n\n" substring. The new behavior makes all multiline string output
      as single text block which is handier for the reader, but may be incompatible
      with some existing applications that rely on the old style.

      https://tarantool.io/compat/yaml_pretty_multiline
    default: new
  ...
NO_WRAP

To achieve that, we have to remove the option name from the usage error
message but it seems to be okay because such errors shouldn't happen in
practice and the error message is clear enough to figure out what went
wrong.

Follow-up #8807

NO_DOC=refactoring
NO_CHANGELOG=refactoring

(cherry picked from commit 75b5fd05)
parent 66dc4e59
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment