class RubyEventStore::Browser::Routing

Attributes

host[R]
root_path[R]

Public Class Methods

new(host, root_path) click to toggle source
# File lib/ruby_event_store/browser/routing.rb, line 4
def initialize(host, root_path)
  @host = host
  @root_path = root_path
end

Public Instance Methods

api_url() click to toggle source
# File lib/ruby_event_store/browser/routing.rb, line 17
def api_url
  "#{base_url}/api"
end
events_url() click to toggle source
# File lib/ruby_event_store/browser/routing.rb, line 13
def events_url
  "#{api_url}/events"
end
paginated_events_from_stream_url(id:, position: nil, direction: nil, count: nil) click to toggle source
# File lib/ruby_event_store/browser/routing.rb, line 25
def paginated_events_from_stream_url(id:, position: nil, direction: nil, count: nil)
  stream_name = Rack::Utils.escape(id)
  query_string = URI.encode_www_form({
    "page[position]" => position,
    "page[direction]" => direction,
    "page[count]" => count,
  }.compact)

  if query_string.empty?
    "#{api_url}/streams/#{stream_name}/relationships/events"
  else
    "#{api_url}/streams/#{stream_name}/relationships/events?#{query_string}"
  end
end
root_url() click to toggle source
# File lib/ruby_event_store/browser/routing.rb, line 9
def root_url
  base_url
end
streams_url() click to toggle source
# File lib/ruby_event_store/browser/routing.rb, line 21
def streams_url
  "#{api_url}/streams"
end

Private Instance Methods

base_url() click to toggle source
# File lib/ruby_event_store/browser/routing.rb, line 43
def base_url
  [host, root_path].join
end