Sha256: 4b664716ed934b3051f50e8042b2d4ac7fbc409fcb481fd7f494762695cf7602

Contents?: true

Size: 1.22 KB

Versions: 12

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require 'easy/jsonapi/name_value_pair_collection'

module JSONAPI
  # header_collection # { include: Include, sort: Sort, filter: Filter } 
  class HeaderCollection < JSONAPI::NameValuePairCollection
    
    # 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
    def initialize(header_arr = [])
      super(header_arr, item_type: JSONAPI::HeaderCollection::Header)
    end

    # Add a header to the collection. (CASE-INSENSITIVE).
    # @param header [JSONAPI::HeaderCollection::Header] The header to add
    def add(header)
      super(header) { |hdr| hdr.name.downcase.gsub(/-/, '_') }
    end

    # Call super's get but make it case insensitive
    # @param key [Symbol] The hash key associated with a header
    def get(key)
      super(key.to_s.downcase.gsub(/-/, '_'))
    end

    # #empyt? provided by super
    # #include provided by super
    # add provided by super
    # #each provided from super
    # #remove provided from super
    # #keys provided by super
    # #size provided by super

  end  
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
easy-jsonapi-1.0.11 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.10 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.9 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.8 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.7 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.6 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.5 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.4 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.3 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.2 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.1 lib/easy/jsonapi/header_collection.rb
easy-jsonapi-1.0.0 lib/easy/jsonapi/header_collection.rb