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

Version Path
infopark_fiona_connector-7.0.1.5.2.3.rc4 lib/rails_connector/link_list.rb
infopark_fiona_connector-7.0.1 lib/rails_connector/link_list.rb
infopark_fiona_connector-7.0.1.beta2 lib/rails_connector/link_list.rb
infopark_fiona_connector-7.0.0 lib/rails_connector/link_list.rb
infopark_fiona_connector-6.10.0.beta1 lib/rails_connector/link_list.rb
infopark_rails_connector-6.9.4 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.9.3.1.36404185 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.9.2.1.125136549 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.9.1.3.22208381 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.9.0.3.197272233 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.3.174.51542603 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.3.115.227021242 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.3.73.75172665 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.3.2.153416031 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.3.67.110847540 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.3.1.23895778 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.2.36.82613853 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.2.7.128454143 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.1.26.236500544 app/models/rails_connector/link_list.rb
infopark_rails_connector-6.8.1 app/models/rails_connector/link_list.rb