Sha256: ddb9c6c849b17f840394035e993e1e9604e18f491b4ab70b4e661ce14b54118d

Contents?: true

Size: 758 Bytes

Versions: 24

Compression:

Stored size: 758 Bytes

Contents

module Brightcontent
  module BaseControllerExt
    module Fields
      extend ActiveSupport::Concern

      included do
        %w[list_fields filter_fields form_fields default_fields].each do |name|
          class_eval <<-RUBY, __FILE__, __LINE__ + 1
            def self.#{name}(*fields)
              define_method(:#{name}) { fields.flatten }
            end
            helper_method :#{name}
          RUBY
        end
      end

      protected

      def list_fields
        default_fields
      end

      def filter_fields
        []
      end

      def form_fields
        default_fields
      end

      def default_fields
        resource_class.brightcontent_columns - %w{id created_at updated_at password_digest}
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
brightcontent-core-2.1.3 lib/brightcontent/base_controller_ext/fields.rb
brightcontent-core-2.1.2 lib/brightcontent/base_controller_ext/fields.rb
brightcontent-core-2.1.1 lib/brightcontent/base_controller_ext/fields.rb
brightcontent-core-2.1.0 lib/brightcontent/base_controller_ext/fields.rb