Sha256: 2a2aa046e8fc5aca249eb058e2233f5b7e14cb47e4944d309206cec0c07db2b0

Contents?: true

Size: 703 Bytes

Versions: 7

Compression:

Stored size: 703 Bytes

Contents

module AdminIt
  class FieldFilter < Filter
    class << self
      attr_reader :field

      protected

      def default_display_name
        field.nil? ? superclass.default_display_name : field.display_name
      end
    end

    class_attr_reader :field

    def self.create(name, _resource, _field)
      field_class = create_class(name, _resource)
      field_class.class_eval do
        _field = _field.to_sym if _field.is_a?(String)
        @field =
          if _field <= Field
            _field
          elsif _field.is_a?(Symbol)
            @resource.fields.find { |fld| fld.field_name == _field }
          else
            nil
          end
      end
      field_class
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
admin_it-1.0.7 lib/admin_it/filters/field_filter.rb
admin_it-1.0.6 lib/admin_it/filters/field_filter.rb
admin_it-1.0.5 lib/admin_it/filters/field_filter.rb
admin_it-1.0.4 lib/admin_it/filters/field_filter.rb
admin_it-1.0.3 lib/admin_it/filters/field_filter.rb
admin_it-1.0.2 lib/admin_it/filters/field_filter.rb
admin_it-1.0.1 lib/admin_it/filters/field_filter.rb