Sha256: 79b9254427393d7a97cf9c894729b08be63ab30984f2c44cba4f434a5ae1567b

Contents?: true

Size: 598 Bytes

Versions: 19

Compression:

Stored size: 598 Bytes

Contents

module Carnival::FieldRenderers
  class SingleRelationRenderer < FieldRenderer
    def render_field(model)
      field = @presenter.get_field(@field_name)

      related_presenter_name = @presenter.get_related_class(field.association_name)
      related_presenter_name.gsub!(/.*[(::)\/]/, '')
      related_presenter = @presenter.presenter_to_field_sym(related_presenter_name)

      related_model = model.send(field.association_name)
      { field_type: related_presenter.field_type(field.association_field_name),
        value: related_model.try(field.association_field_name) }
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
carnival-0.2.8 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.2.7 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.2.6 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.2.5 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.2.4 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.2.3 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.10 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.2.2 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.2.1 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.2.0 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.9 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.8 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.7 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.6 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.5 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.3 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.2 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.1 app/helpers/carnival/field_renderers/single_relation_renderer.rb
carnival-0.1.0 app/helpers/carnival/field_renderers/single_relation_renderer.rb