Sha256: e857173d5e078e04c85712381f94fdcb090f7306e734164dd76f5f127a220a74

Contents?: true

Size: 776 Bytes

Versions: 1

Compression:

Stored size: 776 Bytes

Contents

module Hari::Node::Queries::Relation
  module Backend
    module List
      extend self

      def fetch(node, options = {})
        list = node.list list_name(options)
        send "fetch_#{options[:result]}", list, options
      end

      def fetch_relations_ids(list, options = {})
        start = options.fetch(:from, 0)
        stop  = options.limit(:limit, -1)

        list.range start, stop
      end

      def fetch_nodes_ids(list, options)
        index = list.name =~ /in$/ ? 1 : 2
        fetch_relations_ids(list, options).map { |r| r.split(':')[index] }
      end

      def fetch_count(list, options)
        list.count
      end

      private

      def list_name(options)
        "#{options[:relation]}:#{options[:direction]}"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hari-0.0.3 lib/hari/node/queries/relation/backend/list.rb