Sha256: 3a8107288a507cfbb17a911fc20997932f2b37169bf815155b04b066b913c877

Contents?: true

Size: 1.43 KB

Versions: 7

Compression:

Stored size: 1.43 KB

Contents

module ActiveScaffold
  module Helpers
    # Helpers that assist with the rendering of a List Column
    module ShowColumnHelpers
      def show_column_value(record, column)
        # check for an override helper
        if (method = show_column_override(column))
          # we only pass the record as the argument. we previously also passed the formatted_value,
          # but mike perham pointed out that prohibited the usage of overrides to improve on the
          # performance of our default formatting. see issue #138.
          send(method, record, column)
        # second, check if the dev has specified a valid list_ui for this column
        elsif column.list_ui && (method = override_show_column_ui(column.list_ui))
          send(method, record, column)
        else
          if column.column && (method = override_show_column_ui(column.column.type))
            send(method, record, column)
          else
            get_column_value(record, column)
          end
        end
      end

      def active_scaffold_show_text(record, column)
        simple_format(clean_column_value(record.send(column.name)))
      end

      def show_column_override(column)
        override_helper column, 'show_column'
      end

      # the naming convention for overriding show types with helpers
      def override_show_column_ui(list_ui)
        method = "active_scaffold_show_#{list_ui}"
        method if respond_to? method
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
active_scaffold-3.4.22 lib/active_scaffold/helpers/show_column_helpers.rb
active_scaffold-3.4.21.1 lib/active_scaffold/helpers/show_column_helpers.rb
active_scaffold-3.4.21 lib/active_scaffold/helpers/show_column_helpers.rb
active_scaffold-3.4.20 lib/active_scaffold/helpers/show_column_helpers.rb
active_scaffold-3.4.19 lib/active_scaffold/helpers/show_column_helpers.rb
active_scaffold-3.4.18.1 lib/active_scaffold/helpers/show_column_helpers.rb
active_scaffold-3.4.18 lib/active_scaffold/helpers/show_column_helpers.rb