Commit abb1881fa03f354ea0069a24a7886ca260ad9bc7
Committed by
Paulo Meireles
1 parent
e68a8596
Exists in
master
and in
29 other branches
[Mezuro] Begginning of refactoring design to MVC, created project and repository models
Showing
3 changed files
with
46 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,35 @@ |
1 | +class Kalibro::Project < Kalibro::Model | |
2 | + attr_accessor :name, :license, :description, :repository, :configuration_name, :state, :error | |
3 | + | |
4 | + def self.all_names | |
5 | + request(:get_project_names)[:project_name] | |
6 | + end | |
7 | + | |
8 | + def self.find_by_name(project_name) | |
9 | + attributes = request(:get_project, :project_name => project_name)[:project] | |
10 | + new attributes | |
11 | + end | |
12 | + | |
13 | + def save | |
14 | + self.class.request(:save_project, {:project => to_hash}) | |
15 | + end | |
16 | + | |
17 | + def repository=(value) | |
18 | + @repository = (value.kind_of?(Hash)) ? Kalibro::Repository.new(value) : value | |
19 | + end | |
20 | + | |
21 | + private | |
22 | + | |
23 | + def self.client | |
24 | + endpoint = "Project" | |
25 | + service_address = YAML.load_file("#{RAILS_ROOT}/plugins/mezuro/service.yaml") | |
26 | + Savon::Client.new("#{service_address}#{endpoint}Endpoint/?wsdl") | |
27 | + end | |
28 | + | |
29 | + def self.request(action, request_body = nil) | |
30 | + response = client.request(:kalibro, action) { soap.body = request_body } | |
31 | + response.to_hash["#{action}_response".to_sym] | |
32 | + end | |
33 | + | |
34 | +end | |
35 | + | ... | ... |