Module: PanStuff::Serializer::Base
- Extended by:
- ActiveSupport::Concern
- Included in:
- ExceptionSerializer, HashSerializer, ObjectSerializer, ResourceErrorsSerializer, ValidationResponseSerializer
- Defined in:
- lib/pan_stuff/serializer/base.rb
Constant Summary collapse
- TRANSFORMS_MAPPING =
{ camel_lower: %i[camelize lower], underscore: :underscore, }.freeze
Instance Method Summary collapse
- #as_json(opts = nil) ⇒ Object
- #run_key_transform!(key) ⇒ Object
- #serializable_hash! ⇒ Object
- #to_h ⇒ Object (also: #to_hash)
Instance Method Details
#as_json(opts = nil) ⇒ Object
17 18 19 |
# File 'lib/pan_stuff/serializer/base.rb', line 17 def as_json(opts = nil) JSON.generate(result, opts) end |
#run_key_transform!(key) ⇒ Object
31 32 33 |
# File 'lib/pan_stuff/serializer/base.rb', line 31 def run_key_transform!(key) key.to_s.send(*transform_method_value).to_sym end |
#serializable_hash! ⇒ Object
27 28 29 |
# File 'lib/pan_stuff/serializer/base.rb', line 27 def serializable_hash! nil end |
#to_h ⇒ Object Also known as: to_hash
21 22 23 |
# File 'lib/pan_stuff/serializer/base.rb', line 21 def to_h result end |