Class: Dommy::PerformanceObserver
- Inherits:
-
Object
- Object
- Dommy::PerformanceObserver
- Includes:
- Internal::ObservableCallback
- Defined in:
- lib/dommy/performance_observer.rb
Overview
‘PerformanceObserver` — stub. Same observe/disconnect shape, with `__trigger__` for tests.
Instance Attribute Summary collapse
-
#callback ⇒ Object
readonly
Returns the value of attribute callback.
Instance Method Summary collapse
- #__js_call__(method, args) ⇒ Object
- #__trigger__(entries) ⇒ Object
- #disconnect ⇒ Object
- #entry_types ⇒ Object
-
#initialize(callback) ⇒ PerformanceObserver
constructor
A new instance of PerformanceObserver.
- #observe(options = nil) ⇒ Object
- #take_records ⇒ Object (also: #takeRecords)
Constructor Details
#initialize(callback) ⇒ PerformanceObserver
Returns a new instance of PerformanceObserver.
13 14 15 16 |
# File 'lib/dommy/performance_observer.rb', line 13 def initialize(callback) @callback = callback @entry_types = [] end |
Instance Attribute Details
#callback ⇒ Object (readonly)
Returns the value of attribute callback.
11 12 13 |
# File 'lib/dommy/performance_observer.rb', line 11 def callback @callback end |
Instance Method Details
#__js_call__(method, args) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dommy/performance_observer.rb', line 44 def __js_call__(method, args) case method when "observe" observe(args[0]) when "disconnect" disconnect when "takeRecords" take_records end end |
#__trigger__(entries) ⇒ Object
40 41 42 |
# File 'lib/dommy/performance_observer.rb', line 40 def __trigger__(entries) invoke_callback(entries) end |
#disconnect ⇒ Object
25 26 27 28 |
# File 'lib/dommy/performance_observer.rb', line 25 def disconnect @entry_types = [] nil end |
#entry_types ⇒ Object
36 37 38 |
# File 'lib/dommy/performance_observer.rb', line 36 def entry_types @entry_types.dup end |
#observe(options = nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/dommy/performance_observer.rb', line 18 def observe( = nil) opts = .is_a?(Hash) ? : {} types = opts["entryTypes"] || opts[:entryTypes] || [opts["type"] || opts[:type]].compact @entry_types = Array(types).map(&:to_s) nil end |
#take_records ⇒ Object Also known as: takeRecords
30 31 32 |
# File 'lib/dommy/performance_observer.rb', line 30 def take_records [] end |