Class: W3cApi::Models::User
- Defined in:
- lib/w3c_api/models/user.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#groups(client = nil) ⇒ Object
Return groups this user is a member of.
-
#specifications(client = nil) ⇒ Object
Return specifications this user has contributed to.
Methods inherited from Base
Class Method Details
.from_response(response) ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/w3c_api/models/user.rb', line 139 def self.from_response(response) transformed_response = transform_keys(response) user = new transformed_response.each do |key, value| case key when :connected_accounts user.connected_accounts = value.map do |account| ConnectedAccount.from_response(account) end when :_links links_data = {} # Handle all standard links value.each do |link_name, link_data| next if link_name == :photos # Handle photos array separately links_data[link_name] = Link.new(href: link_data[:href], title: link_data[:title]) end # Handle photos if present if value[:photos] photos = value[:photos].map do |photo| UserPhoto.new(href: photo[:href], name: photo[:name]) end links_data[:photos] = photos end user._links = UserLinks.new(links_data) else user.send("#{key}=", value) if user.respond_to?("#{key}=") end end user end |
Instance Method Details
#groups(client = nil) ⇒ Object
Return groups this user is a member of
126 127 128 129 130 |
# File 'lib/w3c_api/models/user.rb', line 126 def groups(client = nil) return nil unless client && _links&.groups client.user_groups(id) end |
#specifications(client = nil) ⇒ Object
Return specifications this user has contributed to
133 134 135 136 137 |
# File 'lib/w3c_api/models/user.rb', line 133 def specifications(client = nil) return nil unless client && _links&.specifications client.user_specifications(id) end |