Class: Plutonium::UI::Form::Concerns::RendersNestedResourceFields::NestedFieldContext Private
- Inherits:
-
Object
- Object
- Plutonium::UI::Form::Concerns::RendersNestedResourceFields::NestedFieldContext
- 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
- #definition ⇒ Object readonly private
- #name ⇒ Object readonly private
- #options ⇒ Object readonly private
- #permitted_fields ⇒ Object readonly private
Instance Method Summary collapse
- #blank_object ⇒ Object private
-
#initialize(name:, definition:, resource_class:, resource_definition:, object_class:) ⇒ NestedFieldContext
constructor
private
A new instance of NestedFieldContext.
- #nested_attribute_options ⇒ Object private
- #nested_fields_input_param ⇒ Object private
- #nested_fields_multiple? ⇒ Boolean private
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 = @permitted_fields = build_permitted_fields @object_class = object_class end |
Instance Attribute Details
#definition ⇒ Object (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 |
#name ⇒ Object (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 |
#options ⇒ Object (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 end |
#permitted_fields ⇒ Object (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_object ⇒ Object
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 || [:class])&.new end |
#nested_attribute_options ⇒ Object
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 ||= @resource_class.[@name] || {} end |
#nested_fields_input_param ⇒ Object
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 |