Sha256: d4adaefa6fadca584a63a441bd2e490fcca40b1e88b5b0eb95e21236a46fdb51

Contents?: true

Size: 753 Bytes

Versions: 19

Compression:

Stored size: 753 Bytes

Contents

module AdminIt
  #
  class FieldFilter < Filter
    dsl do
      dsl_accessor :field
    end

    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

19 entries across 19 versions & 1 rubygems

Version Path
admin_it-1.3.8 lib/admin_it/filters/field_filter.rb
admin_it-1.3.7 lib/admin_it/filters/field_filter.rb
admin_it-1.3.6 lib/admin_it/filters/field_filter.rb
admin_it-1.3.5 lib/admin_it/filters/field_filter.rb
admin_it-1.3.4 lib/admin_it/filters/field_filter.rb
admin_it-1.3.3 lib/admin_it/filters/field_filter.rb
admin_it-1.3.2 lib/admin_it/filters/field_filter.rb
admin_it-1.3.1 lib/admin_it/filters/field_filter.rb
admin_it-1.3.0 lib/admin_it/filters/field_filter.rb
admin_it-1.2.8 lib/admin_it/filters/field_filter.rb
admin_it-1.2.7 lib/admin_it/filters/field_filter.rb
admin_it-1.2.6 lib/admin_it/filters/field_filter.rb
admin_it-1.2.5 lib/admin_it/filters/field_filter.rb
admin_it-1.2.4 lib/admin_it/filters/field_filter.rb
admin_it-1.2.3 lib/admin_it/filters/field_filter.rb
admin_it-1.2.2 lib/admin_it/filters/field_filter.rb
admin_it-1.2.1 lib/admin_it/filters/field_filter.rb
admin_it-1.2.0 lib/admin_it/filters/field_filter.rb
admin_it-1.1.0 lib/admin_it/filters/field_filter.rb