Class: JSONAPIHelpers::Params::Fields

Inherits:
Object
  • Object
show all
Defined in:
lib/jsonapi_helpers/params/fields.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fields_params) ⇒ Fields

Returns a new instance of Fields.



8
9
10
11
12
13
14
15
# File 'lib/jsonapi_helpers/params/fields.rb', line 8

def initialize(fields_params)
  @fields_params = {}
  (fields_params || {}).each do |model_name, value|
    @fields_params[model_name] = value.split(',').map do |name|
      StringSupport.underscore(name.strip)
    end
  end
end

Instance Attribute Details

#fields_paramsObject (readonly)

Returns the value of attribute fields_params.



6
7
8
# File 'lib/jsonapi_helpers/params/fields.rb', line 6

def fields_params
  @fields_params
end

Instance Method Details

#to_hObject



17
18
19
# File 'lib/jsonapi_helpers/params/fields.rb', line 17

def to_h
  fields_params
end