Class: W3cApi::Models::Ecosystem

Inherits:
Base
  • Object
show all
Defined in:
lib/w3c_api/models/ecosystem.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

transform_keys

Class Method Details

.from_response(response) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/w3c_api/models/ecosystem.rb', line 53

def self.from_response(response)
  transformed_response = transform_keys(response)

  ecosystem = new
  transformed_response.each do |key, value|
    case key
    when :_links
      links = value.each_with_object({}) do |(link_name, link_data), acc|
        acc[link_name] = Link.new(href: link_data[:href], title: link_data[:title])
      end
      ecosystem._links = EcosystemLinks.new(links)
    else
      ecosystem.send("#{key}=", value) if ecosystem.respond_to?("#{key}=")
    end
  end
  ecosystem
end

Instance Method Details

#groups(client = nil) ⇒ Object

Return groups in this ecosystem



47
48
49
50
51
# File 'lib/w3c_api/models/ecosystem.rb', line 47

def groups(client = nil)
  return nil unless client && _links&.groups

  client.ecosystem_groups(shortname)
end