Class: ActiveModelSerializers::Adapter::Attributes
- Defined in:
- lib/active_model_serializers/adapter/attributes.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
#instance_options, #serializer
Instance Method Summary collapse
-
#initialize ⇒ Attributes
constructor
A new instance of Attributes.
- #serializable_hash(options = nil) ⇒ Object
Methods inherited from Base
#as_json, #cache_key, cache_key, default_key_transform, #fragment_cache, fragment_cache, inherited, transform, transform_key_casing!
Constructor Details
#initialize ⇒ Attributes
Returns a new instance of Attributes.
6 7 8 9 |
# File 'lib/active_model_serializers/adapter/attributes.rb', line 6 def initialize(*) super [:fieldset] ||= ActiveModel::Serializer::Fieldset.new(fields_to_fieldset(.delete(:fields))) end |
Instance Method Details
#serializable_hash(options = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/active_model_serializers/adapter/attributes.rb', line 11 def serializable_hash( = nil) = (.dup) [:fields] ||= [:fields] serialized_hash = serializer.serializable_hash(, , self) self.class.transform_key_casing!(serialized_hash, ) end |