No commit activity in last 3 years
No release in over 3 years
Map global IDs to models in reflexes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 5.2, < 7.0
 Project Readme

StimulusReflexGlobalid

StimulusReflexGlobalId maps global IDs to instance variables during a reflex.

Installation

bundle add stimulus_reflex_globalid

Usage

No setup is required to use this library.

In your markup, specific data-reflex and data attributes as normal

<button data-reflex="click->MyReflex#handle_click" data-foo="<%= @foo.to_global_id %>"

When the button is clicked, an instance variable @foo will be created, set to @foo.

class MyReflex < ApplicationReflex
  def handle_click
    p @foo
  end
end

You can also use signed IDs.

Configuring

You can turn off signed/unsigned IDs by configuring the gem.

StimulusReflexGlobalid::Engine.configure do |config|
  config.allow_signed = false # default true
  config.allow_unsigned = false # default true
end

License

The gem is available as open source under the terms of the MIT License.