Class: RubyEventStore::Browser::Urls
- Inherits:
-
Object
- Object
- RubyEventStore::Browser::Urls
- Defined in:
- lib/ruby_event_store/browser/urls.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#app_url ⇒ Object
readonly
Returns the value of attribute app_url.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Class Method Summary collapse
Instance Method Summary collapse
- #==(o) ⇒ Object
- #bootstrap_js_url ⇒ Object
- #browser_css_url ⇒ Object
- #browser_js_url ⇒ Object
- #events_url ⇒ Object
-
#initialize(host, root_path, api_url) ⇒ Urls
constructor
A new instance of Urls.
- #paginated_events_from_stream_url(id:, position: nil, direction: nil, count: nil) ⇒ Object
- #streams_url ⇒ Object
- #with_request(request) ⇒ Object
Constructor Details
#initialize(host, root_path, api_url) ⇒ Urls
Returns a new instance of Urls.
20 21 22 23 24 25 26 |
# File 'lib/ruby_event_store/browser/urls.rb', line 20 def initialize(host, root_path, api_url) @host = host @root_path = root_path @app_url = [host, root_path].compact.reduce(:+) @api_url = api_url || ("#{app_url}/api" if app_url) @gem_source = GemSource.new($LOAD_PATH) end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
18 19 20 |
# File 'lib/ruby_event_store/browser/urls.rb', line 18 def api_url @api_url end |
#app_url ⇒ Object (readonly)
Returns the value of attribute app_url.
18 19 20 |
# File 'lib/ruby_event_store/browser/urls.rb', line 18 def app_url @app_url end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
18 19 20 |
# File 'lib/ruby_event_store/browser/urls.rb', line 18 def host @host end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
18 19 20 |
# File 'lib/ruby_event_store/browser/urls.rb', line 18 def root_path @root_path end |
Class Method Details
.from_configuration(host, root_path, api_url = nil) ⇒ Object
6 7 8 |
# File 'lib/ruby_event_store/browser/urls.rb', line 6 def self.from_configuration(host, root_path, api_url = nil) new(host, root_path, api_url) end |
.initial ⇒ Object
10 11 12 |
# File 'lib/ruby_event_store/browser/urls.rb', line 10 def self.initial new(nil, nil, nil) end |
Instance Method Details
#==(o) ⇒ Object
72 73 74 |
# File 'lib/ruby_event_store/browser/urls.rb', line 72 def ==(o) self.class.eql?(o.class) && app_url.eql?(o.app_url) && api_url.eql?(o.api_url) end |
#bootstrap_js_url ⇒ Object
68 69 70 |
# File 'lib/ruby_event_store/browser/urls.rb', line 68 def bootstrap_js_url "#{app_url}/bootstrap.js" end |
#browser_css_url ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/ruby_event_store/browser/urls.rb', line 59 def browser_css_url name = "ruby_event_store_browser.css" if gem_source.from_git? cdn_file_url(name) else local_file_url(name) end end |
#browser_js_url ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/ruby_event_store/browser/urls.rb', line 50 def browser_js_url name = "ruby_event_store_browser.js" if gem_source.from_git? cdn_file_url(name) else local_file_url(name) end end |
#events_url ⇒ Object
28 29 30 |
# File 'lib/ruby_event_store/browser/urls.rb', line 28 def events_url "#{api_url}/events" end |
#paginated_events_from_stream_url(id:, position: nil, direction: nil, count: nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ruby_event_store/browser/urls.rb', line 36 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 |
#streams_url ⇒ Object
32 33 34 |
# File 'lib/ruby_event_store/browser/urls.rb', line 32 def streams_url "#{api_url}/streams" end |