Sha256: 055c4199961e188fd49969fb329a28195102e390ac6d558338b98dcd5806be53

Contents?: true

Size: 480 Bytes

Versions: 2

Compression:

Stored size: 480 Bytes

Contents

require 'delegate'
module Feedlr
  # When the response is of Array type,
  #  it creates an array of Feedlr::Base or plain types values
  class Collection < SimpleDelegator
    # Initializer
    # @param [Array] data
    # @return [Feedlr::Collection]
    def initialize(data = [])
      super([])
      data.each { |value| self << build_object(value) }
    end

    private

    def build_object(value)
      value.is_a?(Hash) ? Feedlr::Base.new(value) : value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rich_email_validator-0.0.2 collection.rb
rich_email_validator-0.0.1 collection.rb