Ruby YAML parser by passing constructor

后端 未结 3 890
花落未央
花落未央 2021-02-08 18:11

I am working on an application that takes input from a YAML file, parses them into objects, and let\'s them do their thing. The only problem I\'m having now, is that the YAML pa

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 18:44

    from_yaml(input)

    Special loader for YAML files. When a Specification object is loaded from a YAML file, it bypasses the normal Ruby object initialization routine (initialize). This method makes up for that and deals with gems of different ages.

    input can be anything that YAML.load() accepts: String or IO.

    This is the reason that the initialize method was not being run when you executed YAML::Load.

提交回复
热议问题