Class: InertiaRails::DeferProp

Inherits:
IgnoreOnFirstLoadProp show all
Defined in:
lib/inertia_rails/defer_prop.rb

Constant Summary collapse

DEFAULT_GROUP =
'default'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseProp

#call

Constructor Details

#initialize(group: nil, merge: nil, deep_merge: nil, match_on: nil, &block) ⇒ DeferProp

Returns a new instance of DeferProp.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
15
16
17
18
# File 'lib/inertia_rails/defer_prop.rb', line 9

def initialize(group: nil, merge: nil, deep_merge: nil, match_on: nil, &block)
  raise ArgumentError, 'Cannot set both `deep_merge` and `merge` to true' if deep_merge && merge

  super(&block)

  @group = group || DEFAULT_GROUP
  @merge = merge || deep_merge
  @deep_merge = deep_merge
  @match_on = match_on.nil? ? nil : Array(match_on)
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



7
8
9
# File 'lib/inertia_rails/defer_prop.rb', line 7

def group
  @group
end

#match_onObject (readonly)

Returns the value of attribute match_on.



7
8
9
# File 'lib/inertia_rails/defer_prop.rb', line 7

def match_on
  @match_on
end

Instance Method Details

#deep_merge?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/inertia_rails/defer_prop.rb', line 24

def deep_merge?
  @deep_merge
end

#merge?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/inertia_rails/defer_prop.rb', line 20

def merge?
  @merge
end