Class: ActiveModel::Serializer::Fieldset

Inherits:
Object
  • Object
show all
Defined in:
lib/active_model/serializer/fieldset.rb

Instance Method Summary collapse

Constructor Details

#initialize(fields) ⇒ Fieldset

Returns a new instance of Fieldset.



4
5
6
# File 'lib/active_model/serializer/fieldset.rb', line 4

def initialize(fields)
  @raw_fields = fields || {}
end

Instance Method Details

#fieldsObject



8
9
10
# File 'lib/active_model/serializer/fieldset.rb', line 8

def fields
  @fields ||= parsed_fields
end

#fields_for(type) ⇒ Object



12
13
14
# File 'lib/active_model/serializer/fieldset.rb', line 12

def fields_for(type)
  fields[type.singularize.to_sym] || fields[type.pluralize.to_sym]
end