Class: Opendaylight::ModelDriven
- Inherits:
-
Object
- Object
- Opendaylight::ModelDriven
show all
- Defined in:
- lib/opendaylight/model_driven.rb
Instance Method Summary
collapse
Constructor Details
#initialize(resource_chain = nil) ⇒ ModelDriven
Returns a new instance of ModelDriven.
6
7
8
9
|
# File 'lib/opendaylight/model_driven.rb', line 6
def initialize(resource_chain = nil)
@resource_chain = resource_chain ? resource_chain : Array.new
@auth = {:username => Opendaylight.configuration.username, :password => Opendaylight.configuration.password}
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/opendaylight/model_driven.rb', line 23
def method_missing(sym, *args, &block)
@resource_chain << sym
args.each do |arg|
@resource_chain << arg.to_s.to_sym
end
md = ModelDriven.new(@resource_chain)
@resource_chain = Array.new
return md
super(sym, *args, &block)
end
|
Instance Method Details
#create(post_data) ⇒ Object
11
12
13
14
15
|
# File 'lib/opendaylight/model_driven.rb', line 11
def create(post_data)
h = HTTParty.post(form_url_from_method_calls, { :basic_auth => @auth, :body => post_data, headers: {"Content-Type" => "application/json", "Accept" => "application/json"} } )
h.response
end
|
#delete ⇒ Object
17
18
19
20
21
|
# File 'lib/opendaylight/model_driven.rb', line 17
def delete
h = HTTParty.delete(form_url_from_method_calls, { :basic_auth => @auth } )
h.response
end
|
#resource ⇒ Object
47
48
49
50
51
|
# File 'lib/opendaylight/model_driven.rb', line 47
def resource
url = form_url_from_method_calls
h = HTTParty.get(url, { :basic_auth => @auth, headers: {"Accept" => "application/json"} } )
h.response
end
|
#respond_to?(sym, include_private = false) ⇒ Boolean
42
43
44
45
|
# File 'lib/opendaylight/model_driven.rb', line 42
def respond_to?(sym, include_private = false)
@resource_chain << sym.to_s.to_sym
call_exists_in_mdsal? || super(sym, include_private)
end
|
#update(object) ⇒ Object
36
37
38
39
40
|
# File 'lib/opendaylight/model_driven.rb', line 36
def update(object)
h = HTTParty.put(form_url_from_method_calls, { :basic_auth => @auth, :body => object, headers: {"Content-Type" => "application/json", "Accept" => "application/json"} } )
h.response
end
|