Module: InertiaRails::PropMergeable
- Included in:
- DeferProp, MergeProp, ScrollProp
- Defined in:
- lib/inertia_rails/prop_mergeable.rb
Instance Attribute Summary collapse
-
#appends_at_paths ⇒ Object
readonly
Returns the value of attribute appends_at_paths.
-
#match_on ⇒ Object
readonly
Returns the value of attribute match_on.
-
#prepends_at_paths ⇒ Object
readonly
Returns the value of attribute prepends_at_paths.
Instance Method Summary collapse
- #appends_at_root? ⇒ Boolean
- #deep_merge? ⇒ Boolean
- #initialize(**props, &block) ⇒ Object
- #merge? ⇒ Boolean
- #merges_at_root? ⇒ Boolean
- #prepends_at_root? ⇒ Boolean
Instance Attribute Details
#appends_at_paths ⇒ Object (readonly)
Returns the value of attribute appends_at_paths.
5 6 7 |
# File 'lib/inertia_rails/prop_mergeable.rb', line 5 def appends_at_paths @appends_at_paths end |
#match_on ⇒ Object (readonly)
Returns the value of attribute match_on.
5 6 7 |
# File 'lib/inertia_rails/prop_mergeable.rb', line 5 def match_on @match_on end |
#prepends_at_paths ⇒ Object (readonly)
Returns the value of attribute prepends_at_paths.
5 6 7 |
# File 'lib/inertia_rails/prop_mergeable.rb', line 5 def prepends_at_paths @prepends_at_paths end |
Instance Method Details
#appends_at_root? ⇒ Boolean
23 24 25 |
# File 'lib/inertia_rails/prop_mergeable.rb', line 23 def appends_at_root? @append && merges_at_root? end |
#deep_merge? ⇒ Boolean
39 40 41 |
# File 'lib/inertia_rails/prop_mergeable.rb', line 39 def deep_merge? @deep_merge end |
#initialize(**props, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/inertia_rails/prop_mergeable.rb', line 7 def initialize(**props, &block) raise ArgumentError, 'Cannot set both `deep_merge` and `merge` to true' if props[:deep_merge] && props[:merge] @deep_merge = props.fetch(:deep_merge, false) @merge = props[:merge] || @deep_merge @match_on = props[:match_on].nil? ? nil : Array(props[:match_on]) @appends_at_paths = [] @prepends_at_paths = [] @append = true append(props[:append]) if props.key?(:append) prepend(props[:prepend]) if props.key?(:prepend) super end |
#merge? ⇒ Boolean
35 36 37 |
# File 'lib/inertia_rails/prop_mergeable.rb', line 35 def merge? @merge end |
#merges_at_root? ⇒ Boolean
31 32 33 |
# File 'lib/inertia_rails/prop_mergeable.rb', line 31 def merges_at_root? merge? && appends_at_paths.none? && prepends_at_paths.none? end |
#prepends_at_root? ⇒ Boolean
27 28 29 |
# File 'lib/inertia_rails/prop_mergeable.rb', line 27 def prepends_at_root? !@append && merges_at_root? end |