Skip to content

Change behavour of add_tab #587

@stoivo

Description

@stoivo

Description

I find the api to add_tab very strange. Why is there such a huge diffence between hashes and arrays?

The current codes looks like

    def add_tab(name, value)
      return if name.nil?

      if value.is_a? Hash
        meta_data[name] ||= {}
        meta_data[name].merge! value
      else
        meta_data["custom"] = {} unless meta_data["custom"]

        meta_data["custom"][name.to_s] = value
      end
    end

I suggest

    def add_tab(name, value)
      return if name.nil?

      meta_data[name.to_sym] ||= {}
      meta_data[name].merge!(value.is_a? Hash ? value : {name.to_sym => value})
    end

I was very confused when I added one tab called details and it appeared in the web view as CUSTOM.

It's not realy a issue since I will just wrap slimiar to what I did in my changes. I can open a PR if you are interested in the chang. I think it makes the api more unifor, therefor betterm. On the other hand it chages the behavour so someone might be supprces if it changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions