class Unpoly::Rails::Change::Layer
Attributes
change[R]
context[R]
TODO: Docs
mode[R]
TODO: Docs
Public Class Methods
new(change, mode:, context:)
click to toggle source
# File lib/unpoly/rails/change/layer.rb, line 7 def initialize(change, mode:, context:) @change = change @mode = mode.presence || 'root' @context = context end
Public Instance Methods
accept(value = nil)
click to toggle source
TODO: Docs
# File lib/unpoly/rails/change/layer.rb, line 41 def accept(value = nil) overlay? or raise CannotClose, 'Cannot accept the root layer' change.response.headers['X-Up-Accept-Layer'] = value.to_json end
dismiss(value = nil)
click to toggle source
TODO: Docs
# File lib/unpoly/rails/change/layer.rb, line 48 def dismiss(value = nil) overlay? or raise CannotClose, 'Cannot dismiss the root layer' change.response.headers['X-Up-Dismiss-Layer'] = value.to_json end
emit(type, options = {})
click to toggle source
TODO: Docs
# File lib/unpoly/rails/change/layer.rb, line 35 def emit(type, options = {}) change.emit(type, options.merge(layer: 'current')) end
overlay?()
click to toggle source
TODO: Docs
# File lib/unpoly/rails/change/layer.rb, line 23 def overlay? not root? end
root?()
click to toggle source
TODO: Docs
# File lib/unpoly/rails/change/layer.rb, line 29 def root? mode == 'root' end