Sha256: 8084cc08c0c622ecad1a6be2ca176b2aaec477f4c8b1b15c094ff36445339e40

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

# -*- encoding : utf-8 -*-
require 'ashikawa-core/document'
require 'equalizer'

module Ashikawa
  module Core
    # A certain Edge within a certain Collection
    class Edge < Document
      include Equalizer.new(:id, :revision, :from_id, :to_id)

      # The ID of the 'from' document
      #
      # @return [String]
      # @api public
      # @example Get the ID for the 'from' Document
      #   document = Ashikawa::Core::Edge.new(database, raw_document)
      #   document.from_id # => 'my_fancy_collection/2345678'
      attr_reader :from_id

      # The ID of the 'to' document
      #
      # @return [String]
      # @api public
      # @example Get the ID for the 'to' Document
      #   document = Ashikawa::Core::Edge.new(database, raw_document)
      #   document.to_id # => 'my_fancy_collection/2345678'
      attr_reader :to_id

      # Initialize an Edge with the database and raw data
      #
      # @param [Database] _database
      # @param [Hash] raw_edge
      # @param [Hash] _additional_data
      # @api public
      # @example Create an Edge
      #   document = Ashikawa::Core::Edge.new(database, raw_edge)
      def initialize(_database, raw_edge, _additional_data = {})
        @from_id = raw_edge['_from']
        @to_id = raw_edge['_to']
        super
      end

      protected

      # Send a request for this edge with the given opts
      #
      # @param [Hash] opts Options for this request
      # @return [Hash] The parsed response from the server
      # @api private
      def send_request_for_document(opts)
        @database.send_request("edge/#{@id}", opts)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ashikawa-core-0.12.0 lib/ashikawa-core/edge.rb
ashikawa-core-0.11.0 lib/ashikawa-core/edge.rb
ashikawa-core-0.10.0 lib/ashikawa-core/edge.rb