Sha256: 161b8205f9399a07c7f301879ea07beb903b5a7807a07588eb9407129dd8703d

Contents?: true

Size: 1.06 KB

Versions: 5

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Aranha
  module Selenium
    class Session < ::SimpleDelegator
      class FormRequest
        class Field
          class << self
            # @param source [Enumeration, Hash]
            # @return [Array<Aranha::Selenium::Session::FormRequest::Field>]
            def assert_all(source)
              if source.is_a?(::Hash)
                assert_all_from_hash(source)
              elsif source.is_a?(::Enumeration)
                assert_all_from_enumerable(source)
              else
                raise ::ArgumentError, "Invalid source type: #{source.class}"
              end
            end

            private

            def assert_all_from_enumerable(source)
              source.map { |e| new(*e) }
            end

            def assert_all_from_hash(source)
              source.map { |k, v| new(k, v) }
            end
          end

          common_constructor :name, :value

          # @return [String]
          def to_js_object
            "'#{name}': '#{value}'"
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
aranha-selenium-0.11.1 lib/aranha/selenium/session/form_request/field.rb
aranha-selenium-0.11.0 lib/aranha/selenium/session/form_request/field.rb
aranha-selenium-0.10.1 lib/aranha/selenium/session/form_request/field.rb
aranha-selenium-0.10.0 lib/aranha/selenium/session/form_request/field.rb
aranha-selenium-0.9.0 lib/aranha/selenium/session/form_request/field.rb