Sha256: a97e4fd474e222788863e99946726d8407a231286e3c9b777966f5450a479550

Contents?: true

Size: 749 Bytes

Versions: 4

Compression:

Stored size: 749 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

4 entries across 4 versions & 1 rubygems

Version Path
admin_it-1.0.11 lib/admin_it/filters/field_filter.rb
admin_it-1.0.10 lib/admin_it/filters/field_filter.rb
admin_it-1.0.9 lib/admin_it/filters/field_filter.rb
admin_it-1.0.8 lib/admin_it/filters/field_filter.rb