Commit 3cc6ecfe50c8f9424b4404f5da440ede27db25e4
Committed by
Paulo Meireles
1 parent
66fb1ebe
Exists in
master
and in
29 other branches
[Mezuro] Begginning of refactoring design to MVC, created project and repository models
Showing
2 changed files
with
5 additions
and
5 deletions
Show diff stats
plugins/mezuro/lib/kalibro/model.rb
... | ... | @@ -3,7 +3,7 @@ class Kalibro::Model |
3 | 3 | def initialize(attributes={}) |
4 | 4 | attributes.each { |field, value| send("#{field}=", value) if self.class.is_valid?(field) } |
5 | 5 | end |
6 | - | |
6 | + | |
7 | 7 | def to_hash |
8 | 8 | hash = Hash.new |
9 | 9 | fields.each do |field| |
... | ... | @@ -39,7 +39,7 @@ class Kalibro::Model |
39 | 39 | instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '').to_sym } |
40 | 40 | end |
41 | 41 | |
42 | - def convert_to_hash(value) | |
42 | + def convert_to_hash(value) | |
43 | 43 | return value if value.nil? |
44 | 44 | return value.collect { |element| convert_to_hash(element) } if value.is_a?(Array) |
45 | 45 | return value.to_hash if value.is_a?(Kalibro::Model) | ... | ... |
plugins/mezuro/lib/kalibro/project.rb
... | ... | @@ -5,7 +5,7 @@ class Kalibro::Project < Kalibro::Model |
5 | 5 | def self.all_names |
6 | 6 | request("Project", :get_project_names)[:project_name] |
7 | 7 | end |
8 | - | |
8 | + | |
9 | 9 | def self.find_by_name(project_name) |
10 | 10 | new request("Project", :get_project, :project_name => project_name)[:project] |
11 | 11 | end |
... | ... | @@ -18,7 +18,7 @@ class Kalibro::Project < Kalibro::Model |
18 | 18 | :repository => { |
19 | 19 | :type => content.repository_type, |
20 | 20 | :address => content.repository_url |
21 | - }, | |
21 | + }, | |
22 | 22 | :configuration_name => content.configuration_name |
23 | 23 | }).save |
24 | 24 | end |
... | ... | @@ -26,7 +26,7 @@ class Kalibro::Project < Kalibro::Model |
26 | 26 | def destroy |
27 | 27 | self.class.request("Project", :remove_project, {:project_name => name}) |
28 | 28 | end |
29 | - | |
29 | + | |
30 | 30 | def save |
31 | 31 | begin |
32 | 32 | self.class.request("Project", :save_project, {:project => to_hash}) | ... | ... |