Sha256: 61c875950b4de3f3f57caf1fc4d048a27cabfbc16336c72ec12a890ff9a23ab6
Contents?: true
Size: 621 Bytes
Versions: 5
Compression:
Stored size: 621 Bytes
Contents
# frozen_string_literal: true module ActiveModel class Serializer class Fieldset def initialize(fields) @raw_fields = fields || {} end def fields @fields ||= parsed_fields end def fields_for(type) fields[type.to_s.singularize.to_sym] || fields[type.to_s.pluralize.to_sym] end protected attr_reader :raw_fields private def parsed_fields if raw_fields.is_a?(Hash) raw_fields.each_with_object({}) { |(k, v), h| h[k.to_sym] = v.map(&:to_sym) } else {} end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems