Sha256: a2b4e0a7df95e226922ac0eb56dbaead89b2f6c11938b68f7effb19237eb4764

Contents?: true

Size: 1.01 KB

Versions: 12

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require 'easy/jsonapi/name_value_pair_collection'
require 'easy/jsonapi/request/query_param_collection/fields_param'
require 'easy/jsonapi/utility'

module JSONAPI
  class Request
    class QueryParamCollection < NameValuePairCollection
      class FieldsParam < QueryParam
        # Collection of fields related to specific resource objects
        class Fieldset

          attr_reader :resource_type, :fields

          # @param field_arr [Array<JSONAPI::Field>]
          #   A fieldset is a collection of Resource Fields
          def initialize(resource_type, field_arr = [])
            @resource_type = resource_type
            @fields = field_arr
          end

          # Represention of Fieldset as a string where fields
          #   are comma separated strings
          def to_s
            pre_string = "fields[#{@resource_type}]="
            JSONAPI::Utility.to_string_collection(@fields, delimiter: ',', pre_string: pre_string)
          end

        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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