Class: RMeetup::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rmeetup/client.rb

Overview

RMeetup::Client

Essentially a simple wrapper to delegate requests to different fetcher classes who are responsible for fetching and parsing their own responses.

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) {|Configuration| ... } ⇒ RMeetup::Client

Initializes a new Client object

Parameters:

  • opts (Hash) (defaults to: {})

    Options, currenlty only for providing clinet with the auth data

Yields:

  • (Configuration)

    , object with accessors :api_key and :access_token, used for providing auth data in a backward compatible way



30
31
32
33
34
35
36
37
38
# File 'lib/rmeetup/client.rb', line 30

def initialize(opts = {})
  if not(opts.empty?)
    configuration.api_key = opts[:api_key] if opts.has_key?(:api_key)
    configuration.access_token = opts[:access_token] if opts.has_key?(:access_token)
  else
    yield(configuration) if block_given?
  end
  check_configuration!
end

Instance Method Details

#fetch(type, options = {}) ⇒ Object

Delegates to appropriate RMeetup::Fetcher



41
42
43
# File 'lib/rmeetup/client.rb', line 41

def fetch(type, options = {})
  RMeetup::Fetcher.for(type).fetch options.merge(auth)
end

#post(type, options = {}) ⇒ Object

Delegates to appropriate RMeetup::Poster



46
47
48
# File 'lib/rmeetup/client.rb', line 46

def post(type, options = {})
  RMeetup::Poster.for(type).post options.merge(auth)
end