Method: JSONAPI::Collection#initialize
- Defined in:
- lib/easy/jsonapi/collection.rb
#initialize(arr_of_obj = [], item_type: Object) {|item| ... } ⇒ Collection
Assume collection is empty not innitialized with an array of objects. for block { |item| item }
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/easy/jsonapi/collection.rb', line 12 def initialize(arr_of_obj = [], item_type: Object, &block) @item_type = item_type @collection = {} return unless (arr_of_obj != []) && block_given? arr_of_obj.each do |obj| add(obj, &block) end end |