Class: Glib::JsonUi::ActionBuilder
- Inherits:
-
AbstractBuilder
- Object
- AbstractBuilder
- Glib::JsonUi::ActionBuilder
- Defined in:
- app/helpers/glib/json_ui/action_builder/bottom_banners.rb,
app/helpers/glib/json_ui/action_builder.rb,
app/helpers/glib/json_ui/action_builder/iap.rb,
app/helpers/glib/json_ui/action_builder/http.rb,
app/helpers/glib/json_ui/action_builder/files.rb,
app/helpers/glib/json_ui/action_builder/tours.rb,
app/helpers/glib/json_ui/action_builder/fields.rb,
app/helpers/glib/json_ui/action_builder/logics.rb,
app/helpers/glib/json_ui/action_builder/panels.rb,
app/helpers/glib/json_ui/action_builder/sheets.rb,
app/helpers/glib/json_ui/action_builder/dialogs.rb,
app/helpers/glib/json_ui/action_builder/windows.rb,
app/helpers/glib/json_ui/action_builder/browsers.rb,
app/helpers/glib/json_ui/action_builder/commands.rb,
app/helpers/glib/json_ui/action_builder/popovers.rb,
app/helpers/glib/json_ui/action_builder/snackbars.rb,
app/helpers/glib/json_ui/action_builder/components.rb,
app/helpers/glib/json_ui/action_builder/global_states.rb,
app/helpers/glib/json_ui/action_builder/storage_items.rb
Overview
deprecated
Defined Under Namespace
Modules: Analytics, Auth, BottomBanners, Browsers, Cables, Commands, Components, Cookies, Devices, Dialogs, Fields, Files, Forms, GlobalStates, Http, Iap, Labels, Lists, Logics, Panels, Popovers, Sheets, Snackbars, StorageItems, Timeouts, Tours, Windows Classes: Action, RunMultiple
Instance Attribute Summary collapse
-
#singleton_action_name ⇒ Object
readonly
Returns the value of attribute singleton_action_name.
-
#singleton_action_set ⇒ Object
readonly
Returns the value of attribute singleton_action_set.
Attributes inherited from AbstractBuilder
Instance Method Summary collapse
-
#initialize(json, page, multiple) ⇒ ActionBuilder
constructor
A new instance of ActionBuilder.
- #method_missing(m, *args) ⇒ Object
- #reset_singleton_tracking! ⇒ Object
- #restore_singleton_tracking!(action_set, action_name) ⇒ Object
-
#with_isolated_singleton_tracking ⇒ Object
Runs block with fresh singleton-tracking state, then restores whatever was there before — even if the block raises.
Constructor Details
#initialize(json, page, multiple) ⇒ ActionBuilder
Returns a new instance of ActionBuilder.
4 5 6 7 8 |
# File 'app/helpers/glib/json_ui/action_builder.rb', line 4 def initialize(json, page, multiple) super(json, page) @multiple = multiple end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/glib/json_ui/action_builder.rb', line 37 def method_missing(m, *args) if @multiple add_element_to_array_v1 'action', m, *args else if !Rails.env.production? && @singleton_action_set raise "Multiple actions called on a singleton ActionBuilder. " \ "Only one action is allowed. Previous action: '#{@singleton_action_name}', " \ "current action: '#{m}'. Use `run_multiple` with `childActions` or " \ "chain actions using `onClose` callbacks." end @singleton_action_set = true @singleton_action_name = m add_singleton_element_v1 'action', m, *args end end |
Instance Attribute Details
#singleton_action_name ⇒ Object (readonly)
Returns the value of attribute singleton_action_name.
10 11 12 |
# File 'app/helpers/glib/json_ui/action_builder.rb', line 10 def singleton_action_name @singleton_action_name end |
#singleton_action_set ⇒ Object (readonly)
Returns the value of attribute singleton_action_set.
10 11 12 |
# File 'app/helpers/glib/json_ui/action_builder.rb', line 10 def singleton_action_set @singleton_action_set end |
Instance Method Details
#reset_singleton_tracking! ⇒ Object
12 13 14 15 |
# File 'app/helpers/glib/json_ui/action_builder.rb', line 12 def reset_singleton_tracking! @singleton_action_set = false @singleton_action_name = nil end |
#restore_singleton_tracking!(action_set, action_name) ⇒ Object
17 18 19 20 |
# File 'app/helpers/glib/json_ui/action_builder.rb', line 17 def restore_singleton_tracking!(action_set, action_name) @singleton_action_set = action_set @singleton_action_name = action_name end |
#with_isolated_singleton_tracking ⇒ Object
Runs block with fresh singleton-tracking state, then restores whatever was there before — even if the block raises. Used around user-provided callbacks (onLoad, onUnload, etc.) so that their action state doesn’t leak out and trip the singleton guard on later actions.
26 27 28 29 30 31 32 33 34 35 |
# File 'app/helpers/glib/json_ui/action_builder.rb', line 26 def with_isolated_singleton_tracking saved_set = @singleton_action_set saved_name = @singleton_action_name reset_singleton_tracking! begin yield ensure restore_singleton_tracking!(saved_set, saved_name) end end |