Class: Mirrored::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/mirrored/base.rb

Direct Known Subclasses

Date, Post, Tag, Update

Class Method Summary collapse

Class Method Details

.api_urlObject



31
32
33
# File 'lib/mirrored/base.rb', line 31

def self.api_url
  API_URL[@@service]
end

.connectionObject



39
40
41
# File 'lib/mirrored/base.rb', line 39

def self.connection
  @@connection
end

.establish_connection(s, u, p) ⇒ Object

Sets up the login information for either magnolia or delicious.

Usage:

Mirrored::Base.establish_connection(:delicious, 'jnunemaker', 'password')
Mirrored::Base.establish_connection(:magnolia, 'jnunemaker', 'password')

Raises:



14
15
16
17
18
19
# File 'lib/mirrored/base.rb', line 14

def self.establish_connection(s, u, p)
  remove_connection
  raise InvalidService unless valid_service?(s)
  @@service = s
  @@connection = Connection.new(api_url, :username => u, :password => p)
end

.remove_connectionObject

Removes the current connection information



22
23
24
# File 'lib/mirrored/base.rb', line 22

def self.remove_connection
  @@service, @@connection = nil, nil
end

.serviceObject



35
36
37
# File 'lib/mirrored/base.rb', line 35

def self.service
  @@service
end

.valid_service?(s) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


26
27
28
29
# File 'lib/mirrored/base.rb', line 26

def self.valid_service?(s) #:nodoc:
  s = s.nil? ? '' : s
  API_URL.keys.include?(s)
end