Permalink
Browse files

Updated to 0.10.1.dev

  • Loading branch information...
1 parent e69a782 commit f5bc21dbdd0009ac6487b487cf30bb9089129a3d @rscottm rscottm committed Dec 8, 2012
Showing with 15 additions and 4 deletions.
  1. +15 −4 src/ruboto/service.rb
View
@@ -14,20 +14,31 @@
module Ruboto
module Context
- def start_ruboto_service(global_variable_name = '$service', klass=RubotoService, &block)
+ def start_ruboto_service(global_variable_name='$service', klass=RubotoService, options={}, &block)
+ # FIXME(uwe): Translate old positional signature to new options-based signature.
+ # FIXME(uwe): Remove when we stop supporting Ruboto 0.8.0 or older.
+ if options.nil?
+ if global_variable_name.is_a?(Hash)
+ options = global_variable_name
+ else
+ options = {}
+ end
+ global_variable_name = nil
+ end
+
class_name = options[:class_name] || "#{klass.name.split('::').last}_#{source_descriptor(block)[0].split("/").last.gsub(/[.-]+/, '_')}_#{source_descriptor(block)[1]}"
if !Object.const_defined?(class_name)
Object.const_set(class_name, Class.new(&block))
else
Object.const_get(class_name).class_eval(&block) if block_given?
end
b = Java::android.os.Bundle.new
- b.putInt("Theme", theme) if theme
b.putString("ClassName", class_name)
+ b.putString("Script", options[:script]) if options[:script]
i = android.content.Intent.new
i.setClass self, klass.java_class
- i.putExtra("RubotoActivity Config", b)
- self.startService Java::android.content.Intent.new(self, klass.java_class)
+ i.putExtra("Ruboto Config", b)
+ self.startService i
self
end
end

0 comments on commit f5bc21d

Please sign in to comment.