class GitHub::Helper

Singleton class, that is used globally

Public Class Methods

build_from_yaml(yaml) click to toggle source

Recognizing objects retrieved from GitHub, creating new and assigning parameters from YAML

Objects

More to be added soon @deprecated Nothing uses it, but may come handy later @param [String] yaml a YAML content to be parsed @return [GitHub::User, Array]

# File lib/github-api-client/base.rb, line 97
def self.build_from_yaml(yaml)
  yaml = YAML::load yaml
  object = case
    when yaml.has_key?('user') then [GitHub::User, 'user']
    when yaml.has_key?('users') then [[GitHub::User], 'users']
  end
  if object.first.class == Array
    objects = []
    yaml[object[1]].each do |single_yaml|
      o = object.first.first.new
      o.build single_yaml
      objects << o
    end
    objects
  else
    object[0] = object.first.new
    object.first.build yaml[object[1]]
    object.first
  end
end