class SimpleRepresenter::Collection
Attributes
collection[R]
options[R]
representer[R]
Public Class Methods
new(representer, collection = [], options = {})
click to toggle source
# File lib/simple_representer/collection.rb, line 9 def initialize(representer, collection = [], options = {}) @representer = representer @collection = collection @options = options end
Public Instance Methods
to_h()
click to toggle source
# File lib/simple_representer/collection.rb, line 15 def to_h collection.map { |elem| representer.new(elem, **options).to_h } end
Also aliased as: to_hash
to_json(*_args)
click to toggle source
# File lib/simple_representer/collection.rb, line 20 def to_json(*_args) ::Oj.dump(to_h, { mode: :compat }) end