class JSONAPI::HeaderCollection
header_collection # { include: Include, sort: Sort, filter: Filter }
Public Class Methods
new(header_arr = [])
click to toggle source
Initialize as empty if a array of Header
objects not passed to it. @param header_arr [JSONAPI::HeaderCollection::Header] The array of Header
objects that can be used to init
a Header collection
@return JSONAPI::HeaderCollection
Calls superclass method
JSONAPI::NameValuePairCollection::new
# File lib/easy/jsonapi/header_collection.rb, line 13 def initialize(header_arr = []) super(header_arr, item_type: JSONAPI::HeaderCollection::Header) end
Public Instance Methods
add(header)
click to toggle source
Add a header to the collection. (CASE-INSENSITIVE). @param header [JSONAPI::HeaderCollection::Header] The header to add
Calls superclass method
JSONAPI::NameValuePairCollection#add
# File lib/easy/jsonapi/header_collection.rb, line 19 def add(header) super(header) { |hdr| hdr.name.downcase.gsub(/-/, '_') } end
get(key)
click to toggle source
Call super's get but make it case insensitive @param key [Symbol] The hash key associated with a header
Calls superclass method
JSONAPI::Collection#get
# File lib/easy/jsonapi/header_collection.rb, line 25 def get(key) super(key.to_s.downcase.gsub(/-/, '_')) end