Commit 97d0870a614468701ec34fd0de72cf0f44043f3e
Committed by
Paulo Meireles
1 parent
988fe3ed
Exists in
staging
and in
42 other branches
[Mezuro] Added configuration model but is still having problems with Savon::SOAP::Responses
Showing
1 changed file
with
52 additions
and
0 deletions
Show diff stats
@@ -0,0 +1,52 @@ | @@ -0,0 +1,52 @@ | ||
1 | +class Kalibro::Configuration < Kalibro::Model | ||
2 | + | ||
3 | + attr_accessor :name, :description, :metric_configuration | ||
4 | + | ||
5 | + def metric_configuration=(value) | ||
6 | + @metric_configuration = to_objects_array(value, Kalibro::MetricConfiguration) | ||
7 | + end | ||
8 | + | ||
9 | + def metric_configurations | ||
10 | + if @metric_configuration != nil | ||
11 | + @metric_configuration | ||
12 | + else | ||
13 | + [] | ||
14 | + end | ||
15 | + end | ||
16 | + | ||
17 | + def metric_configurations=(metric_configurations) | ||
18 | + @metric_configuration = metric_configurations | ||
19 | + end | ||
20 | + | ||
21 | + def self.find_by_name(configuration_name) | ||
22 | + begin | ||
23 | + new request("Configuration", :get_configuration, {:configuration_name => configuration_name})[:configuration] | ||
24 | + rescue Exception => error | ||
25 | + nil | ||
26 | + end | ||
27 | + end | ||
28 | + | ||
29 | + def self.create(configuration_content) | ||
30 | + new ({ | ||
31 | + :name => configuration_content.name, | ||
32 | + :description => configuration_content.description | ||
33 | + }).save | ||
34 | + end | ||
35 | + | ||
36 | + def save | ||
37 | + begin | ||
38 | + self.class.request("Configuration", :save_configuration, {:configuration => to_hash}) | ||
39 | + true | ||
40 | + rescue | ||
41 | + false | ||
42 | + end | ||
43 | + end | ||
44 | + | ||
45 | + def self.all_names | ||
46 | + request("Configuration", :get_configuration_names)[:configuration_name] | ||
47 | + end | ||
48 | + | ||
49 | + def destroy | ||
50 | + self.class.request("Configuration", :remove_configuration, {:configuration_name => name}) | ||
51 | + end | ||
52 | +end |