From a118f77e5e52af1895cb16076e72d9a5e3f9299d Mon Sep 17 00:00:00 2001 From: Pablo Brasero Date: Thu, 13 Feb 2020 10:25:10 +0000 Subject: [PATCH] Accessible from templates; avoids having to create new field types (#1513) Over at https://github.com/thoughtbot/administrate/issues/612, a fair point was made: if field `options` were public, they could be accessed from templates. This would enable users to customize fields without having to create new field types, which I find a bit more cumbersome. An argument against this change would be that it increases the contact surface of field types, which can be an issue later if we change the interface of fields. An argument for this change would be that the interface of fields is unlikely to change radically at this point. If it did, probably subclasses would have to change anyway too, possibly forcing more significant changes than that of how to access the options. --- lib/administrate/field/base.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/administrate/field/base.rb b/lib/administrate/field/base.rb index d8792dd259..44166d779c 100644 --- a/lib/administrate/field/base.rb +++ b/lib/administrate/field/base.rb @@ -40,12 +40,10 @@ def to_partial_path "/fields/#{self.class.field_type}/#{page}" end - attr_reader :attribute, :data, :page, :resource + attr_reader :attribute, :data, :options, :page, :resource protected - attr_reader :options - def self.field_type to_s.split("::").last.underscore end