SimpleForm.use_namespace(:admin)doSimpleForm.setupdo|config|# some config for admin onlyendend
extend
# frozen_string_literal: truerequire'simple_form'require'simple_form/form_builder'moduleSimpleFormmoduleNamespaceextendActiveSupport::ConcernDEFAULT_VALUES=SimpleForm.class_variables.index_with{|k|SimpleForm.class_variable_get(k)}defcurrent_wrapperscurrent_configuration[:@@wrappers]enddefuse_namespace(name=:default)old_namespace=current_namespaceswitch_namespace(name)yieldensureswitch_namespace(old_namespace)enddefswitch_namespace(namespace)Thread.current[:simple_form_namespace]=namespaceenddefcurrent_namespaceThread.current[:simple_form_namespace]||=:defaultenddefbuilder_discovery_cachecurrent_configuration[:@@discovery_cache]||={}enddefcustom_wrapper_mappingscurrent_configuration[:@@custom_wrapper_mappings]||={}endendextendNamespace@configurations={}defself.current_configuration@configurations[current_namespace]||=Namespace::DEFAULT_VALUES.deep_dupendSimpleForm.class_variables.eachdo|k|method=k.to_s.tr("@@",'')setter_method="#{method}="ifSimpleForm.respond_to?(setter_method)define_singleton_method(setter_method)do|v|current_configuration[k]=vendendnextunlessSimpleForm.respond_to?(method)define_singleton_method(method)docurrent_configuration[k]endenddefself.wrapper(name)current_wrappers[name.to_s]orraiseWrapperNotFound,"Couldn't find wrapper with name #{name}"end# Define a new wrapper using SimpleForm::Wrappers::Builder# and store it in the given name.defself.wrappers(*args,&block)ifblock_given?options=args.extract_options!name=args.first||:defaultcurrent_wrappers[name.to_s]=build(options,&block)elsecurrent_wrappersendendSimpleForm::FormBuilder.define_singleton_method(:discovery_cache)do::SimpleForm.builder_discovery_cacheendend