Sha256: f54afc01d9f631fc283bf2dd152122f96ec9df28b43c42e91ac2370c34cf690d
Contents?: true
Size: 1.19 KB
Versions: 14
Compression:
Stored size: 1.19 KB
Contents
module Ldp class PreferHeaders attr_reader :headers_string def initialize(headers_string="") @headers_string = headers_string end def omit @omit ||= options["omit"] || [] end def include @include ||= options["include"] || [] end def return @return ||= options["return"].first || "" end def include=(vals) @include = Array(vals) serialize end def omit=(vals) @omit = Array(vals) serialize end def return=(vals) @return = Array(vals).first serialize end def to_s headers_string.to_s end private def serialize head_string = [] unless self.return.empty? head_string << "return=#{self.return}" end unless omit.empty? head_string << "omit=\"#{omit.join(" ")}\"" end unless self.include.empty? head_string << "include=\"#{self.include.join(" ")}\"" end @headers_string = head_string.join("; ") end def options headers_string.gsub('"',""). split(";"). map{|x| x.strip.split("=")}. map{|x| { x[0] => x[1].split(" ") }}. inject({}, &:merge) end end end
Version data entries
14 entries across 14 versions & 1 rubygems