module Vidibus::Service::Mongoid

Public Instance Methods

client() click to toggle source

Returns a Client for current service.

# File lib/vidibus/service/mongoid.rb, line 48
def client
  @client ||= Client.new(self)
end
connector?() click to toggle source

Returns true if this service is a connector

# File lib/vidibus/service/mongoid.rb, line 33
def connector?
  @is_connector ||= function == "connector"
end
domain() click to toggle source

Returns url without protocol.

# File lib/vidibus/service/mongoid.rb, line 43
def domain
  url.gsub(/https?:\/\//, "") if url
end
dont_allow_secret_for_connector() click to toggle source

Sets an error if secret is given for Connector service.

# File lib/vidibus/service/mongoid.rb, line 65
def dont_allow_secret_for_connector
  if connector? && secret
    errors.add(:secret, :secret_not_allowed_for_connector)
  end
end
public_data() click to toggle source

Returns publicly requestable data.

# File lib/vidibus/service/mongoid.rb, line 38
def public_data
  attributes.only(%w[uuid function url])
end
realm_required?() click to toggle source
# File lib/vidibus/service/mongoid.rb, line 71
def realm_required?
  !connector? && !this?
end
url=(value) click to toggle source

Removes trailing slash from given value.

# File lib/vidibus/service/mongoid.rb, line 27
def url=(value)
  value.gsub!(/\/+$/, "") if value
  self.write_attribute(:url, value)
end
valid_oauth2_secret?(client_secret) click to toggle source

Returns true if given client_secret matches signature. This method is called from Vidibus' OauthServer when issuing an OAuth token. To prevent sending the service's secret over the network, the ConnectorClient sends a signature instead. TODO: Where to put this method? Wanted to extend this gem with vidius-user gem, but that's not a good idea…

# File lib/vidibus/service/mongoid.rb, line 58
def valid_oauth2_secret?(client_secret)
  client_secret == Vidibus::Secure.sign(uuid, secret)
end