Sha256: 912055fcf25f3822a0a47739d81cc3882938b01d4b75c75d55cd1e8aa5ccab85

Contents?: true

Size: 649 Bytes

Versions: 13

Compression:

Stored size: 649 Bytes

Contents

module Plutonium
  module Core
    module Fields
      module Renderers
        class AssociationRenderer < BasicRenderer
          attr_reader :reflection

          def initialize(name, reflection:, **user_options)
            @reflection = reflection
            super(name, **user_options)
          end

          def render(view_context, record)
            value = record.send(name)
            options = self.options.merge(helper: value.class.include?(Plutonium::Resource::Record) ? :display_association_value : :display_name_of)
            view_context.display_field value:, **options
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
plutonium-0.12.9 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.12.8 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.12.7 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.12.5 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.12.4 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.12.3 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.12.2 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.12.1 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.12.0 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.11.2 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.11.1 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.11.0 lib/plutonium/core/fields/renderers/association_renderer.rb
plutonium-0.8.0 lib/plutonium/core/fields/renderers/association_renderer.rb