Class: CobotClient::NavigationLinkService
- Inherits:
-
Object
- Object
- CobotClient::NavigationLinkService
- Defined in:
- lib/cobot_client/navigation_link_service.rb
Overview
Used to install links into the Cobot navigation of a space.
Instance Method Summary collapse
-
#initialize(api_client, space_sudomain) ⇒ NavigationLinkService
constructor
api_client - an CobotClient::ApiClient access_token - an access token string (owner must be admin of the space to be used).
-
#install_links(new_links) ⇒ Object
Checks if links are already installed and if not installs them.
Constructor Details
#initialize(api_client, space_sudomain) ⇒ NavigationLinkService
api_client - an CobotClient::ApiClient access_token - an access token string (owner must be admin of the space to be used)
8 9 10 11 |
# File 'lib/cobot_client/navigation_link_service.rb', line 8 def initialize(api_client, space_sudomain) @api_client = api_client @subdomain = space_sudomain end |
Instance Method Details
#install_links(new_links) ⇒ Object
Checks if links are already installed and if not installs them.
new_links - any number of ‘CobotClient::NavigationLink`s
Returns the links as ‘[CobotClient::NavigationLink]`
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cobot_client/navigation_link_service.rb', line 18 def install_links(new_links) existing_links = get_links missing_links = new_links.reject do |new_link| existing_links.find do |existing_link| existing_link.section == new_link.section && existing_link.iframe_url == new_link.iframe_url end end created_links = missing_links.map do |link| create_link(link) end existing_links + created_links end |