Class: ActiveModel::Serializer::Fieldset
- Inherits:
-
Object
- Object
- ActiveModel::Serializer::Fieldset
- Defined in:
- lib/active_model/serializer/fieldset.rb
Instance Method Summary collapse
- #fields ⇒ Object
- #fields_for(type) ⇒ Object
-
#initialize(fields) ⇒ Fieldset
constructor
A new instance of Fieldset.
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
#fields ⇒ Object
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 |