Module: Kerio::Api::ChainableMethod

Included in:
Client, Method::Generic
Defined in:
lib/kerio-api/chainable_method.rb

Instance Method Summary collapse

Instance Method Details

#next_method(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/kerio-api/chainable_method.rb', line 4

def next_method(params)
  # prefer special implementation over the generic one
  begin
    source = "kerio-api/method/#{params[:names].join('/')}.rb".downcase
    require source

    method_class = params[:names].inject(Kerio::Api::Method) {|o,c| o.const_get c.capitalize}

  rescue NameError, LoadError => e
    method_class = Kerio::Api::Method::Generic
  end

  method_instance = method_class.new(params)
  return method_instance
end