Sha256: 349aaf353bfed3bfd2240281886da23cfea23ac8d10fe1d0f7c3cb13d0ae5098
Contents?: true
Size: 772 Bytes
Versions: 21
Compression:
Stored size: 772 Bytes
Contents
module RailsConnector class LinkList < Array def initialize(link_definitions) #:nodoc: if link_definitions.blank? super([]) else super(build_links(link_definitions.map(&:symbolize_keys))) end end 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
21 entries across 21 versions & 1 rubygems