Module: InertiaRails::Controller::ClassMethods
- Defined in:
- lib/inertia_rails/controller.rb
Instance Method Summary collapse
- #_inertia_configuration ⇒ Object
- #_inertia_shared_data ⇒ Object
- #inertia_config(**attrs) ⇒ Object
- #inertia_share(attrs = {}, &block) ⇒ Object
- #use_inertia_instance_props ⇒ Object
Instance Method Details
#_inertia_configuration ⇒ Object
40 41 42 43 44 45 |
# File 'lib/inertia_rails/controller.rb', line 40 def _inertia_configuration @_inertia_configuration ||= begin config = superclass.try(:_inertia_configuration) || ::InertiaRails.configuration @inertia_config&.with_defaults(config) || config end end |
#_inertia_shared_data ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/inertia_rails/controller.rb', line 47 def _inertia_shared_data @_inertia_shared_data ||= begin shared_data = superclass.try(:_inertia_shared_data) if @inertia_share && shared_data.present? shared_data + @inertia_share.freeze else @inertia_share || shared_data || [] end.freeze end end |
#inertia_config(**attrs) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/inertia_rails/controller.rb', line 23 def inertia_config(**attrs) config = InertiaRails::Configuration.new(**attrs) if @inertia_config @inertia_config.merge!(config) else @inertia_config = config end end |
#inertia_share(attrs = {}, &block) ⇒ Object
17 18 19 20 21 |
# File 'lib/inertia_rails/controller.rb', line 17 def inertia_share(attrs = {}, &block) @inertia_share ||= [] @inertia_share << attrs.freeze unless attrs.empty? @inertia_share << block if block end |
#use_inertia_instance_props ⇒ Object
33 34 35 36 37 38 |
# File 'lib/inertia_rails/controller.rb', line 33 def use_inertia_instance_props before_action do @_inertia_instance_props = true @_inertia_skip_props = view_assigns.keys + ['_inertia_skip_props'] end end |