Skip to content

Use symbols instead of strings in opts access #360

Closed
@AlbinOS

Description

@AlbinOS

Hi everyone,

First I would like to thanks every contributor for their work on this gem.

I run into a little bit of trouble recently as I wanted to give a name while creating a container using :

container = Docker::Container.create(Cmd: ['ls'], Image: 'base', name: 'testing_stuff')

The parameter name was not taken into account. After some digging, I noticed that the parameter name was extracted from opts using string :

name = opts.delete('name')

As with newer ruby version, the hash syntax of {'x': 'y'} automatically transform the key to a symbol, is it not better to use symbol instead of string to extract value from opts ?

I know that I can use 'name' => 'testing_stuff' to force the usage of string as key but I don't really want to. First because I think using always symbols for key is a good pratice and secondly because I prefer the later syntax.

If you are OK with this, I'll submit a pull request using symbol instead of string while accessing opts and add something for retro-compatibility. Please let me know your thoughts about that.

Thanks and kind regards,
Albin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions