Class: CableReady::Config

Inherits:
Object
  • Object
show all
Includes:
MonitorMixin, Observable, Singleton
Defined in:
lib/cable_ready/config.rb

Overview

This class is a process level singleton shared by all threads: CableReady::Config.instance

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



27
28
29
30
31
32
33
34
# File 'lib/cable_ready/config.rb', line 27

def initialize
  super
  @operation_names = Set.new(default_operation_names)
  @on_failed_sanity_checks = :exit
  @broadcast_job_queue = :default
  @precompile_assets = true
  @updatable_debounce_time = 0.1.seconds
end

Instance Attribute Details

#broadcast_job_queueObject

Returns the value of attribute broadcast_job_queue.



16
17
18
# File 'lib/cable_ready/config.rb', line 16

def broadcast_job_queue
  @broadcast_job_queue
end

#on_failed_sanity_checksObject

Returns the value of attribute on_failed_sanity_checks.



16
17
18
# File 'lib/cable_ready/config.rb', line 16

def on_failed_sanity_checks
  @on_failed_sanity_checks
end

#precompile_assetsObject

Returns the value of attribute precompile_assets.



16
17
18
# File 'lib/cable_ready/config.rb', line 16

def precompile_assets
  @precompile_assets
end

#updatable_debounce_adapterObject

Returns the value of attribute updatable_debounce_adapter.



16
17
18
# File 'lib/cable_ready/config.rb', line 16

def updatable_debounce_adapter
  @updatable_debounce_adapter
end

#updatable_debounce_timeObject

Returns the value of attribute updatable_debounce_time.



16
17
18
# File 'lib/cable_ready/config.rb', line 16

def updatable_debounce_time
  @updatable_debounce_time
end

#verifier_keyObject



40
41
42
# File 'lib/cable_ready/config.rb', line 40

def verifier_key
  @verifier_key || Rails.application.key_generator.generate_key("cable_ready/verifier_key")
end

Instance Method Details

#add_operation_name(name) ⇒ Object



48
49
50
51
52
53
# File 'lib/cable_ready/config.rb', line 48

def add_operation_name(name)
  synchronize do
    @operation_names << name.to_sym
    notify_observers name.to_sym
  end
end

#default_operation_namesObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/cable_ready/config.rb', line 55

def default_operation_names
  Set.new(%i[
    add_css_class
    append
    clear_storage
    console_log
    console_table
    dispatch_event
    go
    graft
    inner_html
    insert_adjacent_html
    insert_adjacent_text
    morph
    notification
    outer_html
    prepend
    push_state
    redirect_to
    reload
    remove
    remove_attribute
    remove_css_class
    remove_storage_item
    replace
    replace_state
    scroll_into_view
    set_attribute
    set_cookie
    set_dataset_property
    set_focus
    set_meta
    set_property
    set_storage_item
    set_style
    set_styles
    set_title
    set_value
    text_content
  ]).freeze
end

#observersObject



36
37
38
# File 'lib/cable_ready/config.rb', line 36

def observers
  @observer_peers&.keys || []
end

#on_new_version_availableObject



19
20
21
# File 'lib/cable_ready/config.rb', line 19

def on_new_version_available
  warn "NOTICE: The `config.on_new_version_available` option has been removed from the CableReady initializer. You can safely remove this option from your initializer."
end

#on_new_version_available=(_) ⇒ Object



23
24
25
# File 'lib/cable_ready/config.rb', line 23

def on_new_version_available=(_)
  warn "NOTICE: The `config.on_new_version_available` option has been removed from the CableReady initializer. You can safely remove this option from your initializer."
end

#operation_namesObject



44
45
46
# File 'lib/cable_ready/config.rb', line 44

def operation_names
  @operation_names.to_a
end