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.
4 5 6 |
# File 'lib/active_model/serializer/fieldset.rb', line 4 def initialize(fields) @raw_fields = fields || {} end |
Instance Method Details
#fields ⇒ Object
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 |