Class: StimulusReflex::Broadcasters::Update
- Inherits:
-
Object
- Object
- StimulusReflex::Broadcasters::Update
- Includes:
- CableReady::Identifiable
- Defined in:
- lib/stimulus_reflex/broadcasters/update.rb
Instance Method Summary collapse
- #html ⇒ Object
-
#initialize(key, value, reflex) ⇒ Update
constructor
A new instance of Update.
- #selector ⇒ Object
Constructor Details
#initialize(key, value, reflex) ⇒ Update
Returns a new instance of Update.
8 9 10 11 12 |
# File 'lib/stimulus_reflex/broadcasters/update.rb', line 8 def initialize(key, value, reflex) @key = key @value = value @reflex = reflex end |
Instance Method Details
#html ⇒ Object
18 19 20 21 22 23 |
# File 'lib/stimulus_reflex/broadcasters/update.rb', line 18 def html return @value unless defined?(ActiveRecord) html = @reflex.render(@key) if @key.is_a?(ActiveRecord::Base) && @value.nil? html = @reflex.render_collection(@key) if @key.is_a?(ActiveRecord::Relation) && @value.nil? html || @value end |
#selector ⇒ Object
14 15 16 |
# File 'lib/stimulus_reflex/broadcasters/update.rb', line 14 def selector @selector ||= identifiable?(@key) ? dom_id(@key) : @key.to_s end |