Module: TwirpRails::ActiveRecordExtension
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/twirp_rails/active_record_extension.rb
Instance Method Summary collapse
-
#to_twirp(*fields_or_class) ⇒ Hash
Converts to twirp hash, used by relation method to_twirp.
Instance Method Details
#to_twirp(*fields_or_class) ⇒ Hash
Converts to twirp hash, used by relation method to_twirp
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/twirp_rails/active_record_extension.rb', line 28 def to_twirp(*fields_or_class) if fields_or_class.empty? && self.class. to_twirp_as_class(self.class.) elsif fields_or_class.one? && fields_or_class.first.is_a?(Class) to_twirp_as_class(fields_or_class.first) elsif fields_or_class.any? to_twirp_as_fields(fields_or_class) else attributes end end |