ref: refs/heads/jr_ntp commit 92757fbe56e026d63c405441627020aa86b25a36 Author: Michal Zugec <mzugec@suse.cz> Date: Mon Aug 31 09:46:19 2009 +0200 implemented routes (default only) --- plugins/network/app/models/route.rb | 51 ++++++++++++++++++++++++++++++++++ plugins/network/app/models/routes.rb | 51 ---------------------------------- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/plugins/network/app/models/route.rb b/plugins/network/app/models/route.rb new file mode 100644 index 0000000..388417d --- /dev/null +++ b/plugins/network/app/models/route.rb @@ -0,0 +1,51 @@ +# = Routing model +# Provides set and gets resources from YaPI network module. +# Main goal is handle YaPI specific calls and data formats. Provides cleaned +# and well defined data. +class Routes + + # default route + attr_accessor :default + + private + + public + + def initialize(kwargs) + @default = kwargs["default"] + end + + # fills route instance with data from YaPI. + # + # +warn+: Doesn't take any parameters. + def Routes.find + response = YastService.Call("YaPI::NETWORK::Read") # hostname: true + ret = Routes.new(response["routes"]) + return ret + end + + # Saves data from model to system via YaPI. Saves only setted data, + # so it support partial safe (e.g. save only new timezone if rest of fields is not set). + def save + settings = { + "default" => @default, + } + YastService.Call("YaPI::NETWORK::Write",{"routes" => settings}) + # TODO success or not? + end + + def to_xml( options = {} ) + xml = options[:builder] ||= Builder::XmlMarkup.new(options) + xml.instruct! unless options[:skip_instruct] + + xml.hostname do + xml.default @default + end + end + + def to_json( options = {} ) + hash = Hash.from_xml(to_xml()) + return hash.to_json + end + +end diff --git a/plugins/network/app/models/routes.rb b/plugins/network/app/models/routes.rb deleted file mode 100644 index 388417d..0000000 --- a/plugins/network/app/models/routes.rb +++ /dev/null @@ -1,51 +0,0 @@ -# = Routing model -# Provides set and gets resources from YaPI network module. -# Main goal is handle YaPI specific calls and data formats. Provides cleaned -# and well defined data. -class Routes - - # default route - attr_accessor :default - - private - - public - - def initialize(kwargs) - @default = kwargs["default"] - end - - # fills route instance with data from YaPI. - # - # +warn+: Doesn't take any parameters. - def Routes.find - response = YastService.Call("YaPI::NETWORK::Read") # hostname: true - ret = Routes.new(response["routes"]) - return ret - end - - # Saves data from model to system via YaPI. Saves only setted data, - # so it support partial safe (e.g. save only new timezone if rest of fields is not set). - def save - settings = { - "default" => @default, - } - YastService.Call("YaPI::NETWORK::Write",{"routes" => settings}) - # TODO success or not? - end - - def to_xml( options = {} ) - xml = options[:builder] ||= Builder::XmlMarkup.new(options) - xml.instruct! unless options[:skip_instruct] - - xml.hostname do - xml.default @default - end - end - - def to_json( options = {} ) - hash = Hash.from_xml(to_xml()) - return hash.to_json - end - -end -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org