plutonium 0.12.9 → 0.12.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/# Plutonium: The pre-alpha demo.md +218 -0
  3. data/app/views/components/form/form_component.html.erb +1 -3
  4. data/app/views/components/interactive_action_form/interactive_action_form_component.html.erb +5 -7
  5. data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.html.erb +2 -2
  6. data/app/views/components/table_search_input/table_search_input_component.html.erb +8 -2
  7. data/app/views/resource/_interactive_resource_action_form.html.erb +1 -1
  8. data/app/views/resource/_resource_details.html.erb +9 -2
  9. data/app/views/resource/_resource_table.html.erb +9 -1
  10. data/lib/generators/pu/core/assets/templates/tailwind.config.js +2 -0
  11. data/lib/generators/pu/core/install/install_generator.rb +1 -1
  12. data/lib/generators/pu/core/install/templates/config/initializers/plutonium.rb +4 -0
  13. data/lib/generators/pu/eject/layout/layout_generator.rb +3 -2
  14. data/lib/generators/pu/eject/shell/shell_generator.rb +3 -2
  15. data/lib/generators/pu/field/input/input_generator.rb +32 -0
  16. data/lib/generators/pu/field/input/templates/.keep +0 -0
  17. data/lib/generators/pu/field/input/templates/input.rb.tt +15 -0
  18. data/lib/generators/pu/field/renderer/renderer_generator.rb +32 -0
  19. data/lib/generators/pu/field/renderer/templates/.keep +0 -0
  20. data/lib/generators/pu/field/renderer/templates/renderer.rb.tt +9 -0
  21. data/lib/generators/pu/gem/annotate/annotate_generator.rb +22 -0
  22. data/lib/generators/pu/gem/annotate/templates/.keep +0 -0
  23. data/lib/generators/pu/gem/annotate/templates/lib/tasks/auto_annotate_models.rake +59 -0
  24. data/lib/plutonium/core/actions/interactive_action.rb +2 -2
  25. data/lib/plutonium/core/associations/renderers/base.rb +77 -0
  26. data/lib/plutonium/core/associations/renderers/factory.rb +0 -2
  27. data/lib/plutonium/core/associations/renderers/has_many_renderer.rb +6 -4
  28. data/lib/plutonium/core/controllers/crud_actions.rb +1 -1
  29. data/lib/plutonium/core/controllers/presentable.rb +3 -3
  30. data/lib/plutonium/core/definers/field_definer.rb +4 -4
  31. data/lib/plutonium/core/definers/{input_definer.rb → field_input_definer.rb} +4 -4
  32. data/lib/plutonium/core/definers/{renderer_definer.rb → field_renderer_definer.rb} +10 -10
  33. data/lib/plutonium/core/fields/inputs/attachment_input.rb +2 -2
  34. data/lib/plutonium/core/fields/inputs/base.rb +76 -10
  35. data/lib/plutonium/core/fields/inputs/checkbox_input.rb +3 -1
  36. data/lib/plutonium/core/fields/inputs/date_time_input.rb +3 -1
  37. data/lib/plutonium/core/fields/inputs/nested_input.rb +36 -21
  38. data/lib/plutonium/core/fields/inputs/noop_input.rb +1 -4
  39. data/lib/plutonium/core/fields/inputs/polymorphic_belongs_to_association_input.rb +8 -7
  40. data/lib/plutonium/core/fields/inputs/simple_form_association_input.rb +4 -5
  41. data/lib/plutonium/core/fields/inputs/simple_form_input.rb +2 -3
  42. data/lib/plutonium/core/fields/renderers/association_renderer.rb +11 -5
  43. data/lib/plutonium/core/fields/renderers/attachment_renderer.rb +3 -10
  44. data/lib/plutonium/core/fields/renderers/base.rb +83 -0
  45. data/lib/plutonium/core/fields/renderers/basic_renderer.rb +3 -17
  46. data/lib/plutonium/core/fields/renderers/factory.rb +0 -1
  47. data/lib/plutonium/core/renderable.rb +20 -0
  48. data/lib/plutonium/helpers/display_helper.rb +1 -1
  49. data/lib/plutonium/resource/controller.rb +1 -1
  50. data/lib/plutonium/resource/policy.rb +1 -1
  51. data/lib/plutonium/resource/presenter.rb +3 -3
  52. data/lib/plutonium/resource/query_object.rb +4 -4
  53. data/lib/plutonium/resource/record.rb +1 -1
  54. data/lib/plutonium/simple_form/attachment_component.rb +1 -1
  55. data/lib/plutonium/version.rb +1 -1
  56. data/package.json +1 -1
  57. metadata +17 -5
  58. data/lib/plutonium/core/associations/renderers/basic_renderer.rb +0 -28
@@ -0,0 +1,77 @@
1
+ module Plutonium
2
+ module Core
3
+ module Associations
4
+ module Renderers
5
+ class Base
6
+ include Plutonium::Core::Renderable
7
+
8
+ attr_reader :name, :reflection
9
+
10
+ def initialize(name, reflection:, **user_options)
11
+ @name = name
12
+ @reflection = reflection
13
+ @user_options = user_options
14
+ end
15
+
16
+ # Sets the record object on the renderer and merges render options.
17
+ #
18
+ # @param record [Object] the record object.
19
+ # @param render_options [Hash] additional options for rendering.
20
+ # @return [self] the renderer instance.
21
+ def with(record:, **render_options)
22
+ @record = record
23
+ @render_options = render_options
24
+ @options = build_options(render_options)
25
+
26
+ self
27
+ end
28
+
29
+ private
30
+
31
+ # Returns the merged options for rendering.
32
+ #
33
+ # @raise [RuntimeError] if accessed before rendering.
34
+ # @return [Hash] the merged options.
35
+ def options
36
+ raise "cannot access #options before calling #with" unless defined?(@options)
37
+
38
+ @options
39
+ end
40
+
41
+ # Returns the record object.
42
+ #
43
+ # @raise [RuntimeError] if accessed before rendering.
44
+ # @return [Object] the record object.
45
+ def record
46
+ raise "cannot access #record before calling #with" unless defined?(@record)
47
+
48
+ @record
49
+ end
50
+
51
+ def renderer_options
52
+ {}
53
+ end
54
+
55
+ def label
56
+ options[:label] || record.class.human_attribute_name(name)
57
+ end
58
+
59
+ # Returns the value of the record's attribute corresponding to the renderer's name.
60
+ #
61
+ # @return [Object] the value of the attribute.
62
+ def value
63
+ record.public_send(name)
64
+ end
65
+
66
+ # Builds the options for rendering by merging renderer options, user options, and render options.
67
+ #
68
+ # @param render_options [Hash] additional options for rendering.
69
+ # @return [Hash] the merged options.
70
+ def build_options(render_options)
71
+ renderer_options.deep_merge(@user_options).deep_merge(render_options)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -17,8 +17,6 @@ module Plutonium
17
17
  end
18
18
 
19
19
  def self.for_resource_association(resource_class, attr_name, **options)
20
- options[:label] ||= resource_class.human_attribute_name(attr_name)
21
-
22
20
  association = resource_class.try(:reflect_on_association, attr_name)
23
21
  raise ArgumentError, "#{attr_name} is not a valid association of #{resource_class}" unless association.present?
24
22
  raise ArgumentError, "#{association.klass} does is not a resource record" unless association.klass.include?(Plutonium::Resource::Record)
@@ -2,12 +2,14 @@ module Plutonium
2
2
  module Core
3
3
  module Associations
4
4
  module Renderers
5
- class HasManyRenderer < BasicRenderer
6
- def render(view_context, record)
7
- view_context.render_component :has_many_panel,
5
+ class HasManyRenderer < Base
6
+ def render
7
+ render_component(
8
+ :has_many_panel,
8
9
  title: label,
9
- src: view_context.resource_url_for(reflection.klass, parent: record),
10
+ src: resource_url_for(reflection.klass, parent: record),
10
11
  **options
12
+ )
11
13
  end
12
14
  end
13
15
  end
@@ -15,7 +15,7 @@ module Plutonium
15
15
  @search_object = current_query_object
16
16
  base_query = policy_scope(resource_class)
17
17
  base_query = @search_object.apply(base_query)
18
- base_query = base_query.send(params[:scope].to_sym) if params[:scope].present?
18
+ base_query = base_query.public_send(params[:scope].to_sym) if params[:scope].present?
19
19
  @pagy, @resource_records = pagy base_query
20
20
  @collection = build_collection
21
21
 
@@ -32,7 +32,7 @@ module Plutonium
32
32
  Plutonium::Core::Ui::Collection.new(
33
33
  resource_class:,
34
34
  records: @resource_records,
35
- fields: current_presenter.defined_renderers_for(*presentable_attributes),
35
+ fields: current_presenter.defined_field_renderers_for(*presentable_attributes),
36
36
  actions: current_presenter.actions,
37
37
  pager: @pagy,
38
38
  search_object: @search_object
@@ -43,7 +43,7 @@ module Plutonium
43
43
  Plutonium::Core::Ui::Detail.new(
44
44
  resource_class:,
45
45
  record: resource_record,
46
- fields: current_presenter.defined_renderers_for(*presentable_attributes),
46
+ fields: current_presenter.defined_field_renderers_for(*presentable_attributes),
47
47
  associations: current_presenter.defined_association_renderers_for(*permitted_associations),
48
48
  actions: current_presenter.actions
49
49
  )
@@ -52,7 +52,7 @@ module Plutonium
52
52
  def build_form
53
53
  Plutonium::Core::Ui::Form.new(
54
54
  record: resource_record,
55
- inputs: current_presenter.defined_inputs_for(*presentable_attributes)
55
+ inputs: current_presenter.defined_field_inputs_for(*presentable_attributes)
56
56
  )
57
57
  end
58
58
 
@@ -4,14 +4,14 @@ module Plutonium
4
4
  module FieldDefiner
5
5
  extend ActiveSupport::Concern
6
6
 
7
- include InputDefiner
8
- include RendererDefiner
7
+ include FieldInputDefiner
8
+ include FieldRendererDefiner
9
9
 
10
10
  private
11
11
 
12
12
  def define_field(name, type: nil, input: nil, renderer: nil, input_options: {}, renderer_options: {})
13
- define_input(name, type:, input:, **input_options)
14
- define_renderer(name, type:, renderer:, **renderer_options)
13
+ define_field_input(name, type:, input:, **input_options)
14
+ define_field_renderer(name, type:, renderer:, **renderer_options)
15
15
  end
16
16
  end
17
17
  end
@@ -1,7 +1,7 @@
1
1
  module Plutonium
2
2
  module Core
3
3
  module Definers
4
- module InputDefiner
4
+ module FieldInputDefiner
5
5
  extend ActiveSupport::Concern
6
6
  include Plutonium::Core::Autodiscovery::InputDiscoverer
7
7
 
@@ -47,14 +47,14 @@ module Plutonium
47
47
  attr_reader :hash
48
48
  end
49
49
 
50
- def defined_inputs_for(*names)
50
+ def defined_field_inputs_for(*names)
51
51
  (names - input_definitions.keys).each do |name|
52
- define_input(name, input: autodiscover_input(name))
52
+ define_field_input(name, input: autodiscover_input(name))
53
53
  end
54
54
  input_definitions.slice(*names)
55
55
  end
56
56
 
57
- def define_input(name, input: nil, type: nil, **options)
57
+ def define_field_input(name, input: nil, type: nil, **options)
58
58
  input_definitions[name] = if input.present?
59
59
  input
60
60
  elsif type.present?
@@ -1,23 +1,23 @@
1
1
  module Plutonium
2
2
  module Core
3
3
  module Definers
4
- module RendererDefiner
4
+ module FieldRendererDefiner
5
5
  extend ActiveSupport::Concern
6
6
  include Plutonium::Core::Autodiscovery::RendererDiscoverer
7
7
 
8
- def defined_renderers_for(*names)
9
- (names - renderer_definitions.keys).each do |name|
10
- define_renderer(name, renderer: autodiscover_renderer(name))
8
+ def defined_field_renderers_for(*names)
9
+ (names - field_renderer_definitions.keys).each do |name|
10
+ define_field_renderer(name, renderer: autodiscover_renderer(name))
11
11
  end
12
- renderer_definitions.slice(*names)
12
+ field_renderer_definitions.slice(*names)
13
13
  end
14
14
 
15
15
  private
16
16
 
17
- def renderer_definitions = @renderer_definitions ||= {}
17
+ def field_renderer_definitions = @field_renderer_definitions ||= {}
18
18
 
19
- def define_renderer(name, renderer: nil, type: nil, **options)
20
- renderer_definitions[name] = if renderer.present?
19
+ def define_field_renderer(name, renderer: nil, type: nil, **options)
20
+ field_renderer_definitions[name] = if renderer.present?
21
21
  renderer
22
22
  elsif type.present?
23
23
  Plutonium::Core::Fields::Renderers::Factory.build(name, type:, **options)
@@ -28,8 +28,8 @@ module Plutonium
28
28
  end
29
29
  end
30
30
 
31
- def renderer_defined?(name)
32
- renderer_definitions.key? name
31
+ def field_renderer_defined?(name)
32
+ field_renderer_definitions.key? name
33
33
  end
34
34
  end
35
35
  end
@@ -5,9 +5,9 @@ module Plutonium
5
5
  class AttachmentInput < SimpleFormInput
6
6
  attr_reader :reflection
7
7
 
8
- def initialize(name, reflection:, **user_options)
8
+ def initialize(name, reflection:, **options)
9
9
  @reflection = reflection
10
- super(name, **user_options)
10
+ super(name, **options)
11
11
  end
12
12
 
13
13
  private
@@ -3,17 +3,23 @@ module Plutonium
3
3
  module Fields
4
4
  module Inputs
5
5
  class Base
6
- attr_reader :name, :user_options
6
+ include Plutonium::Core::Renderable
7
7
 
8
+ attr_reader :name
9
+
10
+ # Initializes the Base input class with a name and user-defined options.
11
+ #
12
+ # @param name [String] the name of the input field.
13
+ # @param user_options [Hash] user-defined options for the input field.
8
14
  def initialize(name, **user_options)
9
15
  @name = name
10
16
  @user_options = user_options
11
17
  end
12
18
 
13
- def render(view_context, f, record, **)
14
- raise NotImplementedError, "#{self.class}#render"
15
- end
16
-
19
+ # Collects parameters matching the input field's name with multi-parameter attributes.
20
+ #
21
+ # @param params [Hash] the parameters to collect from.
22
+ # @return [Hash] the collected parameters.
17
23
  def collect(params)
18
24
  # Handles multi parameter attributes
19
25
  # https://www.cookieshq.co.uk/posts/rails-spelunking-date-select
@@ -26,17 +32,77 @@ module Plutonium
26
32
  # - parameter(1i)
27
33
  # - parameter(2f)
28
34
  regex = /^#{param}(\(\d+[if]?\))?$/
29
- keys = params.select { |key, value| regex.match?(key) }.keys
35
+ keys = params.select { |key, _| regex.match?(key) }.keys
30
36
  params.slice(*keys)
31
37
  end
32
38
 
33
- protected
39
+ # Sets the form and record objects on the input field.
40
+ #
41
+ # @param form [Object] the form object.
42
+ # @param record [Object] the record object.
43
+ # @param render_options [Hash] additional options for rendering.
44
+ def with(form:, record:, **render_options)
45
+ @form = form
46
+ @record = record
47
+ @render_options = render_options
48
+ @options = build_options(render_options)
49
+
50
+ self
51
+ end
52
+
53
+ private
54
+
55
+ # Returns input-specific options, can be overridden by subclasses.
56
+ #
57
+ # @return [Hash] the input-specific options.
58
+ def input_options
59
+ {}
60
+ end
61
+
62
+ # Returns the parameter name for the input field.
63
+ #
64
+ # @return [String] the parameter name.
65
+ def param
66
+ name
67
+ end
68
+
69
+ # Raises an error if #options is accessed before rendering.
70
+ #
71
+ # @raise [RuntimeError] if accessed before rendering.
72
+ # @return [Hash] the rendering options.
73
+ def options
74
+ raise "cannot access #options before calling #with" unless defined?(@options)
34
75
 
35
- def input_options = {}
76
+ @options
77
+ end
36
78
 
37
- def param = name
79
+ # Raises an error if #form is accessed before rendering.
80
+ #
81
+ # @raise [RuntimeError] if accessed before rendering.
82
+ # @return [Object] the form object.
83
+ def form
84
+ raise "cannot access #form before calling #with" unless defined?(@form)
85
+
86
+ @form
87
+ end
38
88
 
39
- def options = @options ||= input_options.deep_merge(@user_options)
89
+ # Raises an error if #record is accessed before rendering.
90
+ #
91
+ # @raise [RuntimeError] if accessed before rendering.
92
+ # @return [Object] the record object.
93
+ def record
94
+ raise "cannot access #record before calling #with" unless defined?(@record)
95
+
96
+ @record
97
+ end
98
+
99
+ # Builds the options for rendering by merging input options, user options, and render options.
100
+ #
101
+ # @param render_options [Hash] additional options for rendering.
102
+ # @return [Hash] the merged options.
103
+ def build_options(render_options)
104
+ input_options.deep_merge(@user_options).deep_merge(render_options)
105
+ end
40
106
  end
41
107
  end
42
108
  end
@@ -5,7 +5,9 @@ module Plutonium
5
5
  class CheckboxInput < SimpleFormInput
6
6
  private
7
7
 
8
- def input_options = {wrapper: :resource_checkbox}
8
+ def input_options
9
+ {wrapper: :resource_checkbox}
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -5,7 +5,9 @@ module Plutonium
5
5
  class DateTimeInput < SimpleFormInput
6
6
  private
7
7
 
8
- def input_options = {wrapper: :resource_multi_select}
8
+ def input_options
9
+ {wrapper: :resource_multi_select}
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -3,52 +3,67 @@ module Plutonium
3
3
  module Fields
4
4
  module Inputs
5
5
  class NestedInput < Base
6
- include Plutonium::Core::Definers::InputDefiner
6
+ include Plutonium::Core::Definers::FieldInputDefiner
7
7
 
8
8
  attr_reader :inputs, :resource_class
9
9
 
10
- def initialize(name, inputs:, resource_class:, allow_destroy:, update_only:, limit:, **user_options)
10
+ def initialize(name, inputs:, resource_class:, allow_destroy:, update_only:, limit:, **options)
11
11
  @inputs = inputs
12
12
  @resource_class = resource_class
13
13
  @allow_destroy = allow_destroy
14
14
  @update_only = update_only
15
15
  @limit = limit
16
16
 
17
- super(name, **user_options)
17
+ super(name, **options)
18
18
  end
19
19
 
20
- def render(view_context, f, record, **opts)
21
- opts = options.deep_merge opts
22
- view_context.render_component :nested_resource_form_fields, form: f, **opts
20
+ def render
21
+ render_component :nested_resource_form_fields, form:, **options
23
22
  end
24
23
 
25
24
  def collect(params)
25
+ nested_params = params[param] || {}
26
+ attributes = (nested_params.keys.first == "0") ? collect_indexed_attributes(nested_params) : collect_single_attributes(nested_params)
27
+ {param => attributes}
28
+ end
29
+
30
+ private
31
+
32
+ def collect_single_attributes(params)
33
+ collected = defined_inputs.collect_all(params)
34
+ collected[:id] = params[:id] if params.key?(:id) && !@update_only
35
+ collected[:_destroy] = params[:_destroy] if @allow_destroy
36
+ collected
37
+ end
38
+
39
+ def collect_indexed_attributes(params)
26
40
  attributes = {}
27
- params[param].each do |index, nested_params|
41
+ params.each do |index, nested_params|
28
42
  collected = defined_inputs.collect_all(nested_params)
29
43
  collected[:id] = nested_params[:id] if nested_params.key?(:id) && !@update_only
30
44
  collected[:_destroy] = nested_params[:_destroy] if @allow_destroy
31
45
  attributes[index] = collected
32
46
  end
33
-
34
- {param => attributes}
47
+ attributes
35
48
  end
36
49
 
37
- private
38
-
39
- def param = :"#{name}_attributes"
50
+ def param
51
+ :"#{name}_attributes"
52
+ end
40
53
 
41
- def input_options = {
42
- name:,
43
- resource_class:,
44
- allow_destroy: @allow_destroy,
45
- update_only: @update_only,
46
- limit: @limit,
47
- inputs: defined_inputs
48
- }
54
+ def input_options
55
+ {
56
+ name:,
57
+ resource_class:,
58
+ allow_destroy: @allow_destroy,
59
+ update_only: @update_only,
60
+ limit: @limit,
61
+ inputs: defined_inputs
62
+ }
63
+ end
49
64
 
50
65
  def defined_inputs
51
- @defined_inputs ||= defined_inputs_for(*inputs)
66
+ @defined_inputs ||= defined_field_inputs_for(*inputs)
52
67
  end
53
68
  end
54
69
  end
@@ -3,10 +3,7 @@ module Plutonium
3
3
  module Fields
4
4
  module Inputs
5
5
  class NoopInput
6
- def initialize(*)
7
- end
8
-
9
- def render(view_context, f, record, **)
6
+ def render
10
7
  end
11
8
 
12
9
  def collect(params)
@@ -3,9 +3,8 @@ module Plutonium
3
3
  module Fields
4
4
  module Inputs
5
5
  class PolymorphicBelongsToAssociationInput < SimpleFormAssociationInput
6
- def render(view_context, f, record, **opts)
7
- opts = options.deep_merge opts
8
- f.input param, **opts
6
+ def render
7
+ form.input param, **options
9
8
  end
10
9
 
11
10
  private
@@ -15,12 +14,11 @@ module Plutonium
15
14
  end
16
15
 
17
16
  def input_options
17
+ collection = @user_options.delete(:collection).presence || associated_classes
18
18
  {
19
19
  as: :grouped_select,
20
+ collection:,
20
21
  label: reflection.name.to_s.humanize,
21
- collection: associated_classes.map { |klass|
22
- [klass.name, klass.all]
23
- }.to_h,
24
22
  group_label_method: :first,
25
23
  group_method: :last, include_blank: "Select One"
26
24
  }
@@ -38,7 +36,10 @@ module Plutonium
38
36
  end
39
37
  end
40
38
  end
41
- associated_classes
39
+
40
+ associated_classes.map { |klass|
41
+ [klass.name, klass.all]
42
+ }.to_h
42
43
  end
43
44
  end
44
45
  end
@@ -5,14 +5,13 @@ module Plutonium
5
5
  class SimpleFormAssociationInput < Base
6
6
  attr_reader :reflection
7
7
 
8
- def initialize(name, reflection:, **user_options)
8
+ def initialize(name, reflection:, **)
9
9
  @reflection = reflection
10
- super(name, **user_options)
10
+ super(name, **)
11
11
  end
12
12
 
13
- def render(view_context, f, record, **opts)
14
- opts = options.deep_merge opts
15
- f.association name, **opts
13
+ def render
14
+ form.association name, **options
16
15
  end
17
16
 
18
17
  private
@@ -3,9 +3,8 @@ module Plutonium
3
3
  module Fields
4
4
  module Inputs
5
5
  class SimpleFormInput < Base
6
- def render(view_context, f, record, **opts)
7
- opts = options.deep_merge opts
8
- f.input name, **opts
6
+ def render
7
+ form.input name, **options
9
8
  end
10
9
  end
11
10
  end
@@ -2,7 +2,7 @@ module Plutonium
2
2
  module Core
3
3
  module Fields
4
4
  module Renderers
5
- class AssociationRenderer < BasicRenderer
5
+ class AssociationRenderer < Base
6
6
  attr_reader :reflection
7
7
 
8
8
  def initialize(name, reflection:, **user_options)
@@ -10,10 +10,16 @@ module Plutonium
10
10
  super(name, **user_options)
11
11
  end
12
12
 
13
- def render(view_context, record)
14
- value = record.send(name)
15
- options = self.options.merge(helper: value.class.include?(Plutonium::Resource::Record) ? :display_association_value : :display_name_of)
16
- view_context.display_field value:, **options
13
+ def render
14
+ display_field value:, **options
15
+ end
16
+
17
+ private
18
+
19
+ def renderer_options
20
+ {
21
+ helper: value.class.include?(Plutonium::Resource::Record) ? :display_association_value : :display_name_of
22
+ }
17
23
  end
18
24
  end
19
25
  end
@@ -2,16 +2,9 @@ module Plutonium
2
2
  module Core
3
3
  module Fields
4
4
  module Renderers
5
- class AttachmentRenderer < BasicRenderer
6
- attr_reader :reflection
7
-
8
- def initialize(name, reflection:, **user_options)
9
- @reflection = reflection
10
- super(name, **user_options)
11
- end
12
-
13
- def render(view_context, record)
14
- view_context.attachment_preview record.send(name), **options
5
+ class AttachmentRenderer < AssociationRenderer
6
+ def render
7
+ attachment_preview value, **options
15
8
  end
16
9
 
17
10
  private