Sha256: f8ee26e0fe4b6c76dc22a2ccd75980e3522bd127183e3dba9d9b6ed6e0859b77
Contents?: true
Size: 797 Bytes
Versions: 32
Compression:
Stored size: 797 Bytes
Contents
module RailsConnector # @api public class LinkList < Array def initialize(link_definitions) if link_definitions.blank? super([]) else super(build_links(link_definitions.map(&:symbolize_keys))) end end # @api public def destination_objects self.map {|link| link.destination_object}.compact end private def build_links(link_definitions) object_ids = link_definitions.map { |link_data| link_data[:destination] }.compact.uniq objects = object_ids.empty? ? [] : Obj.find(object_ids) link_definitions.each_with_object([]) do |link_data, links| link = Link.new(link_data, objects.detect { |o| o && o.id == link_data[:destination] }) links << link if link.active? end end end end
Version data entries
32 entries across 32 versions & 2 rubygems