Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/json_serializer/rails/active_record_patch.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.serialize ⇒ Object
7 8 9 |
# File 'lib/json_serializer/rails/active_record_patch.rb', line 7 def self.serialize self.collect{|model| model.send((model.respond_to? :api_attributes) ? :api_attributes : :to_json).merge({:_class_name => self.first.class.name.downcase.pluralize})}.group_by{|d| d[:_class_name] } end |
Instance Method Details
#serialize ⇒ Object
3 4 5 |
# File 'lib/json_serializer/rails/active_record_patch.rb', line 3 def serialize {"#{self.class.name.downcase.underscore}" => self.send((self.respond_to? :api_attributes) ? :api_attributes : :to_json)} end |