Class: Simperium::Api

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

Direct Known Subclasses

Admin

Instance Method Summary collapse

Constructor Details

#initialize(appname, auth_token, options = {}) ⇒ Api

Returns a new instance of Api.



388
389
390
391
392
393
394
# File 'lib/simperium.rb', line 388

def initialize(appname, auth_token, options={})
    @appname = appname
    @token = auth_token
    @_options = options

    @getitem = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



396
397
398
399
400
401
402
403
404
405
# File 'lib/simperium.rb', line 396

def method_missing(method_sym, *arguments, &block)
    #the first argument is a Symbol, so you need to_s it you want to pattern match
    unless method_sym.to_s =~ /=$/
        if method_sym.to_s == 'spuser'
            @getitem[method_sym] ||= Simperium::SPUser.new(@appname, @token)
        else
            @getitem[method_sym] ||= Simperium::Bucket.new(@appname, @token, method_sym)
        end
    end
end

Instance Method Details

#respond_to?(method_sym, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


407
408
409
410
411
412
413
# File 'lib/simperium.rb', line 407

def respond_to?(method_sym, include_private = false)
  if method_sym.to_s =~ /^(.*)$/
    true
  else
    super
  end
end