Class: Jat::Plugins::JsonApi::Params::Fields::Parse
- Inherits:
-
Object
- Object
- Jat::Plugins::JsonApi::Params::Fields::Parse
- Defined in:
- lib/jat/plugins/json_api/lib/params/fields/parse.rb
Constant Summary collapse
- COMMA =
","
Class Method Summary collapse
-
.call(fields) ⇒ Object
returns Hash { type => [attr1, attr2] }.
Class Method Details
.call(fields) ⇒ Object
returns Hash { type => [attr1, attr2] }
13 14 15 16 17 18 19 20 |
# File 'lib/jat/plugins/json_api/lib/params/fields/parse.rb', line 13 def call(fields) return {} unless fields fields.each_with_object({}) do |(type, attrs_string), obj| attrs = attrs_string.split(COMMA).map!(&:to_sym) obj[type.to_sym] = attrs end end |