Class: F5::Icontrol::RAPI::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/f5/icontrol/rapi/resource.rb

Instance Method Summary collapse

Constructor Details

#initialize(args, credentials) ⇒ Resource

Returns a new instance of Resource.



5
6
7
8
# File 'lib/f5/icontrol/rapi/resource.rb', line 5

def initialize(args, credentials)
  @args = args
  @credentials = credentials
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/f5/icontrol/rapi/resource.rb', line 10

def method_missing(method, *args, &block)
  if @args.key? method.to_s
    return @args[method.to_s]
  end

  potential_collection = "#{method}Reference"
  if @args.key? potential_collection
    link = @args[potential_collection]["link"]
    link.sub! %r{^https?://[A-Za-z0-9\-._]+/}, ""
    return F5::Icontrol::RAPI.new(link, @credentials)
  end
end