Sha256: 0a99208b1c1bae01a991447e6d6c6cba60c5474f744f240b539281cd45cf8345

Contents?: true

Size: 551 Bytes

Versions: 3

Compression:

Stored size: 551 Bytes

Contents

# frozen_string_literal: true

require "dato/local/field_type/file"

module Dato
  module Local
    module FieldType
      class Gallery < Array
        def self.parse(value, repo)
          images = if value
                     value.map { |image| FieldType::File.parse(image, repo) }
                   else
                     []
                   end
          new(images)
        end

        def to_hash(max_depth = 3, current_depth = 0)
          map { |item| item.to_hash(max_depth, current_depth) }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dato-0.8.3 lib/dato/local/field_type/gallery.rb
dato-0.8.2 lib/dato/local/field_type/gallery.rb
dato-0.8.1 lib/dato/local/field_type/gallery.rb