Skip to content

Commit

Permalink
Restore top level methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bootstraponline committed Apr 25, 2013
1 parent b095c4a commit 9668450
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion lib/appium_lib.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
# encoding: utf-8

$last_driver = nil

# Invoke top level methods on last created Appium driver.
def self.method_missing method, *args, &block
raise "driver is nil. called #{method}" if $last_driver == nil

has_args = ! args.empty?
has_block = ! block.nil?

# method with no params
if ! has_args && ! has_block
$last_driver.send method
# method with only arg params
elsif has_args && ! has_block
$last_driver.send method, *args
# method with only block param
elsif ! has_args && has_block
$last_driver.send method, block
# method with arg + block
elsif has_args && has_block
$last_driver.send method, *args, block
end
end

module Appium
def self.add_to_path file, path=false
path = path ? "../#{path}/" : '..'
Expand All @@ -10,4 +35,4 @@ def self.add_to_path file, path=false
add_to_path __FILE__

require 'appium_lib/driver'
end
end

0 comments on commit 9668450

Please sign in to comment.