require 'scrivito/attribute_content' require 'fiona7/type_register' module Scrivito module AttributeContent module ClassMethods # patch attribute to notify type register alias_method :orig_attribute, :attribute def attribute(name, type, options = {}) orig_attribute(name, type, options) ensure if self.name.present? # to_s is friendly to shadowclassing Fiona7::TypeRegister.instance.add_usr_attr(self.to_s, name, type, options[:values]) end end # support shadow classes def description_for_editor to_s.titleize end def register_attribute_definitions(obj_class) type_register = Fiona7::TypeRegister.instance self.attribute_definitions.each do |attribute_definition| # to_s instead of name for shadowclassing type_register.add_usr_attr(obj_class, attribute_definition.name, attribute_definition.type, attribute_definition.values.presence) end end end end end