Module: Contacts

Defined in:
lib/contacts.rb,
lib/contacts/util.rb,
lib/contacts/yahoo.rb,
lib/contacts/google.rb,
lib/contacts/railtie.rb,
lib/contacts/version.rb,
lib/contacts/consumer.rb,
lib/contacts/windows_live.rb,
lib/contacts/oauth_consumer.rb

Defined Under Namespace

Modules: Util, VERSION Classes: Consumer, Contact, Error, Google, OAuthConsumer, Railtie, TooManyRedirects, WindowsLive, Yahoo

Constant Summary collapse

Identifier =
'Ruby Contacts v' + VERSION::STRING

Class Method Summary collapse

Class Method Details

.configure(configuration) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/contacts.rb', line 12

def self.configure(configuration)
  configuration.each do |key, value|
    klass =
      case key.to_s
      when 'google'
        Google
      when 'yahoo'
        Yahoo
      when 'windows_live'
        WindowsLive
      else
        raise ArgumentError, "unknown consumer: #{key}"
      end
    klass.configure(value)
  end
end

.consumer_class_for(name) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/contacts.rb', line 53

def self.consumer_class_for(name)
  class_name = name.to_s.gsub(/(?:\A|_)(.)/){|s| $1.upcase}
  class_name.sub!(/Oauth/, 'OAuth')
  class_name.sub!(/Bbauth/, 'BBAuth')
  begin
    klass = const_get(class_name)
  rescue NameError
    return nil
  end
  klass < Consumer ? klass : nil
end

.deserialize_consumer(name, serialized_data) ⇒ Object



43
44
45
46
# File 'lib/contacts.rb', line 43

def self.deserialize_consumer(name, serialized_data)
  klass = consumer_class_for(name) and
    klass.deserialize(serialized_data)
end

.new(name, *args, &block) ⇒ Object



48
49
50
51
# File 'lib/contacts.rb', line 48

def self.new(name, *args, &block)
  klass = consumer_class_for(name) and
    klass.new(*args, &block)
end

.verbose?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/contacts.rb', line 65

def self.verbose?
  'irb' == $0
end