Sha256: 52386599cce6e2547c58302e388c0f0cf9a802882d53fb02f68e987476b4080a
Contents?: true
Size: 652 Bytes
Versions: 1
Compression:
Stored size: 652 Bytes
Contents
module JsonApiClient module Legacy class LinkDefinition def initialize(spec) @spec = {}.with_indifferent_access spec.each do |type, definition| @spec[type.split(".").last] = definition.merge({slurp: type}) end end def has_link?(type) @spec.has_key?(type) end def attribute_name_for(type) @spec.fetch(type).fetch("type") end def url_for(type, ids) definition = @spec.fetch(type) href = definition.fetch("href") slurp = definition.fetch("slurp") href.gsub("{#{slurp}}", Array(ids).join(",")) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
json_api_client-legacy-1.0.0.beta | lib/json_api_client/legacy/link_definition.rb |