Class: Plutonium::UI::Form::Concerns::RendersNestedResourceFields::NestedFieldContext Private

Inherits:
Object
  • Object
show all
Defined in:
lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, definition:, resource_class:, resource_definition:, object_class:) ⇒ NestedFieldContext

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of NestedFieldContext.



26
27
28
29
30
31
32
33
34
# File 'lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb', line 26

def initialize(name:, definition:, resource_class:, resource_definition:, object_class:)
  @name = name
  @definition = definition
  @resource_definition = resource_definition
  @resource_class = resource_class
  @options = build_options
  @permitted_fields = build_permitted_fields
  @object_class = object_class
end

Instance Attribute Details

#definitionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb', line 24

def definition
  @definition
end

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb', line 24

def name
  @name
end

#optionsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb', line 24

def options
  @options
end

#permitted_fieldsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb', line 24

def permitted_fields
  @permitted_fields
end

Instance Method Details

#blank_objectObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



48
49
50
# File 'lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb', line 48

def blank_object
  (@object_class || nested_attribute_options[:class])&.new
end

#nested_attribute_optionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



36
37
38
# File 'lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb', line 36

def nested_attribute_options
  @nested_attribute_options ||= @resource_class.all_nested_attributes_options[@name] || {}
end

#nested_fields_input_paramObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb', line 40

def nested_fields_input_param
  @options[:as] || :"#{@name}_attributes"
end

#nested_fields_multiple?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
# File 'lib/plutonium/ui/form/concerns/renders_nested_resource_fields.rb', line 44

def nested_fields_multiple?
  @options[:multiple]
end