Module: Voom::Serializer
- Includes:
- Trace
- Defined in:
- lib/voom/serializer.rb
Overview
Simple serializer that will build add a to_hash method to an object by inspecting the intersection of its instance variables and public accessor methods.
Instance Method Summary collapse
Instance Method Details
#to_hash(serializer = true) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/voom/serializer.rb', line 10 def to_hash(serializer=true) trace {self.class.to_s} return build_hash unless serializer begin serializer_name = "#{self.class.to_s}Serializer" serializer = Module.const_get(serializer_name) serializer.new(self).to_hash rescue NameError build_hash end end |