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.



6
7
8
# File 'lib/active_model/serializer/fieldset.rb', line 6

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

Instance Method Details

#fieldsObject



10
11
12
# File 'lib/active_model/serializer/fieldset.rb', line 10

def fields
  @fields ||= parsed_fields
end

#fields_for(type) ⇒ Object



14
15
16
# File 'lib/active_model/serializer/fieldset.rb', line 14

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