Sha256: 22caf5128612a6626aaf852eae3fd569517fcbcbbc258cc6a04e4e152b9fb2bd
Contents?: true
Size: 594 Bytes
Versions: 49
Compression:
Stored size: 594 Bytes
Contents
module Sawyer module LinkParsers class Simple LINK_REGEX = /_?url$/ # Public: Parses simple *_url style links on resources # # data - Hash of resource data # # Returns a Hash of data with separate links Hash def parse(data) links = {} inline_links = data.keys.select {|k| k.to_s[LINK_REGEX] } inline_links.each do |key| rel_name = key.to_s == 'url' ? 'self' : key.to_s.gsub(LINK_REGEX, '') links[rel_name.to_sym] = data[key] end return data, links end end end end
Version data entries
49 entries across 35 versions & 2 rubygems