Skip to content

Commit 4edd949

Browse files
Update self.promote_singleton_appium_methods
1 parent 82a236a commit 4edd949

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

lib/appium_lib/driver.rb

+17-3
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,26 @@ def self.symbolize_keys hash
149149
result
150150
end
151151

152-
def self.promote_singleton_appium_methods main_module
152+
# if modules is a module instead of an array, then the constants of
153+
# that module are promoted on.
154+
# otherwise, the array of modules will be used as the promotion target.
155+
def self.promote_singleton_appium_methods modules
153156
raise 'Driver is nil' if $driver.nil?
154-
main_module.constants.each do |sub_module|
157+
158+
target_modules = []
159+
160+
if modules.is_a? Module
161+
modules.constants.each do |sub_module|
162+
target_modules << modules.const_get(sub_module)
163+
end
164+
else
165+
raise 'modules must be a module or an array' unless modules.is_a? Array
166+
target_modules = modules
167+
end
168+
169+
target_modules.each do |const|
155170
#noinspection RubyResolve
156171
$driver.public_methods(false).each do |m|
157-
const = main_module.const_get(sub_module)
158172
const.send(:define_singleton_method, m) do |*args, &block|
159173
begin
160174
super(*args, &block) # promote.rb

0 commit comments

Comments
 (0)