Sha256: 2fb4e6e6d2a16a2d49147a0716bf9ba2255fe0ddf6f9b692939be4435956f93d

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

require 'ashikawa-core/document'

module Ashikawa
  module Core
    # A certain Edge within a certain Collection
    class Edge < Document
      # 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
      # @api public
      # @example Create an Edge
      #   document = Ashikawa::Core::Edge.new(database, raw_edge)
      def initialize(database, raw_edge)
        @from_id = raw_edge["_from"]
        @to_id = raw_edge["_to"]
        super(database, raw_edge)
      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.7.2 lib/ashikawa-core/edge.rb
ashikawa-core-0.7.1 lib/ashikawa-core/edge.rb
ashikawa-core-0.7.0 lib/ashikawa-core/edge.rb