Class: OpenSRS::OMA

Inherits:
JsonRPC::Client show all
Includes:
ErrorHandler
Defined in:
lib/opensrs/oma.rb

Constant Summary collapse

VERSION =
'0.0.2'
METHODS =

removed, in favour of metaprogramming

%w(  )

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ErrorHandler

#valid?

Methods inherited from JsonRPC::Client

#request

Constructor Details

#initialize(opt = {}) ⇒ OMA



60
61
62
63
64
65
66
67
68
69
# File 'lib/opensrs/oma.rb', line 60

def initialize( opt={} )
  #OMA.create_methods

  @username = opt[:username] || ''
  @password = opt[:password] || ''
  
  @url = opt[:url] || 'https://admin.a.hostedemail.com/api'
  @credentials = { :client => "Ruby OpenSRS::OMA 0.0.2", :user => @username, :password => @password }
  super( @url, @credentials )
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



88
89
90
91
# File 'lib/opensrs/oma.rb', line 88

def method_missing( m, *args, &block )
  @method = m
  request( m, *args )
end

Instance Attribute Details

#methodsObject (readonly)

Returns the value of attribute methods.



58
59
60
# File 'lib/opensrs/oma.rb', line 58

def methods
  @methods
end

#passwordObject

Returns the value of attribute password.



57
58
59
# File 'lib/opensrs/oma.rb', line 57

def password
  @password
end

#urlObject

Returns the value of attribute url.



55
56
57
# File 'lib/opensrs/oma.rb', line 55

def url
  @url
end

#usernameObject

Returns the value of attribute username.



56
57
58
# File 'lib/opensrs/oma.rb', line 56

def username
  @username
end

Class Method Details

.create_methodsObject

This method is deprecated..



79
80
81
82
83
84
85
86
# File 'lib/opensrs/oma.rb', line 79

def self.create_methods
  METHODS.each do |method|
    define_method method do |*argv|
      @method = method
      valid?( request method, *argv )     
    end
  end
end

Instance Method Details

#uri(method = @method) ⇒ Object



71
72
73
# File 'lib/opensrs/oma.rb', line 71

def uri ( method = @method )
  URI.parse( @base + "/" + method.to_s)
end