Sha256: 4b5d023b663d131b59a83b5e6976110d168e38d989d39e8a660ae412689cca27

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

module Appium
  module Core
    module Device
      module Context
        def self.add_methods
          ::Appium::Core::Device.add_endpoint_method(:within_context) do
            def within_context(context)
              existing_context = current_context
              set_context context
              if block_given?
                result = yield
                set_context existing_context
                result
              else
                set_context existing_context
              end
            end
          end

          ::Appium::Core::Device.add_endpoint_method(:switch_to_default_context) do
            def switch_to_default_context
              set_context nil
            end
          end

          ::Appium::Core::Device.add_endpoint_method(:current_context) do
            def current_context
              execute :current_context
            end
          end

          ::Appium::Core::Device.add_endpoint_method(:available_contexts) do
            def available_contexts
              # return empty array instead of nil on failure
              execute(:available_contexts, {}) || []
            end
          end

          ::Appium::Core::Device.add_endpoint_method(:set_context) do
            def set_context(context = null)
              execute :set_context, {}, name: context
            end
          end
        end
      end # module ImeActions
    end # module Device
  end # module Core
end # module Appium

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appium_lib_core-1.7.2 lib/appium_lib_core/device/context.rb
appium_lib_core-1.7.1 lib/appium_lib_core/device/context.rb
appium_lib_core-1.7.0 lib/appium_lib_core/device/context.rb