Module: Kreuzcrawl::PageAction

Extended by:
T::Helpers, T::Sig
Included in:
PageActionClick, PageActionExecuteJs, PageActionPress, PageActionScrape, PageActionScreenshot, PageActionScroll, PageActionTypeText, PageActionWait
Defined in:
lib/kreuzcrawl/native.rb

Overview

A single page interaction action.

Actions are serialized with a ‘type` tag using camelCase naming, except `ExecuteJs` which is explicitly renamed to `“executeJs”`.

Class Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ Object



249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/kreuzcrawl/native.rb', line 249

def self.from_hash(hash)
  discriminator = hash[:type] || hash["type"]
  case discriminator
  when "click" then PageActionClick.from_hash(hash)
  when "type" then PageActionTypeText.from_hash(hash)
  when "press" then PageActionPress.from_hash(hash)
  when "scroll" then PageActionScroll.from_hash(hash)
  when "wait" then PageActionWait.from_hash(hash)
  when "screenshot" then PageActionScreenshot.from_hash(hash)
  when "executeJs" then PageActionExecuteJs.from_hash(hash)
  when "scrape" then PageActionScrape.from_hash(hash)
  else raise "Unknown discriminator: #{discriminator}"
  end
end