Class: ScopedSerializer::CollectionSerializer
- Inherits:
-
ArraySerializer
- Object
- BaseSerializer
- ArraySerializer
- ScopedSerializer::CollectionSerializer
- Defined in:
- lib/scoped_serializer/collection_serializer.rb
Instance Attribute Summary
Attributes inherited from ArraySerializer
Instance Method Summary collapse
-
#initialize(*args) ⇒ CollectionSerializer
constructor
A new instance of CollectionSerializer.
- #to_csv(options = {}) ⇒ Object
Methods inherited from ArraySerializer
Methods inherited from BaseSerializer
#as_json, #default_root_key, #meta, #meta_hash, #set_scope, #to_xls
Constructor Details
#initialize(*args) ⇒ CollectionSerializer
Returns a new instance of CollectionSerializer.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/scoped_serializer/collection_serializer.rb', line 4 def initialize(*args) super = args. # Allow to define own model class @model_class = .delete(:model_class) || @array.klass # Configure root element @options[:root] = default_root_key(@model_class).pluralize if @options[:root].nil? end |
Instance Method Details
#to_csv(options = {}) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/scoped_serializer/collection_serializer.rb', line 16 def to_csv(={}) attributes = ScopedSerializer.find_serializer_by_class(@model_class) .find_scope([:scope] || :default) .attributes super(.merge(:columns => attributes)) end |