Class: JSONAPI::HeaderCollection
- Inherits:
-
NameValuePairCollection
- Object
- Collection
- NameValuePairCollection
- JSONAPI::HeaderCollection
- Defined in:
- lib/easy/jsonapi/header_collection.rb,
lib/easy/jsonapi/header_collection/header.rb
Overview
header_collection # { include: Include, sort: Sort, filter: Filter }
Defined Under Namespace
Classes: Header
Instance Method Summary collapse
-
#add(header) ⇒ Object
Add a header to the collection.
-
#get(key) ⇒ Object
Call super’s get but make it case insensitive.
-
#initialize(header_arr = []) ⇒ Object
constructor
Initialize as empty if a array of Header objects not passed to it.
Methods inherited from NameValuePairCollection
Methods inherited from Collection
#[], #[]=, #each, #empty?, #include?, #insert, #keys, #remove, #set, #size, #to_s
Constructor Details
#initialize(header_arr = []) ⇒ Object
Initialize as empty if a array of Header objects not passed to it.
13 14 15 |
# File 'lib/easy/jsonapi/header_collection.rb', line 13 def initialize(header_arr = []) super(header_arr, item_type: JSONAPI::HeaderCollection::Header) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class JSONAPI::NameValuePairCollection
Instance Method Details
#add(header) ⇒ Object
Add a header to the collection. (CASE-INSENSITIVE).
19 20 21 |
# File 'lib/easy/jsonapi/header_collection.rb', line 19 def add(header) super(header) { |hdr| hdr.name.downcase.gsub(/-/, '_') } end |
#get(key) ⇒ Object
Call super’s get but make it case insensitive
25 26 27 |
# File 'lib/easy/jsonapi/header_collection.rb', line 25 def get(key) super(key.to_s.downcase.gsub(/-/, '_')) end |