Sha256: 19a3c05fa89e98590529cea241c7b825cb71e3fb7f49790fbdf1b468d2d0cd45
Contents?: true
Size: 922 Bytes
Versions: 36
Compression:
Stored size: 922 Bytes
Contents
module ActiveAdmin class DynamicSetting def self.build(setting, type) (type ? klass(type) : self).new(setting) end def self.klass(type) klass = "#{type.to_s.camelcase}Setting" raise ArgumentError, "Unknown type: #{type}" unless ActiveAdmin.const_defined?(klass) ActiveAdmin.const_get(klass) end def initialize(setting) @setting = setting end def value(*_args) @setting end end # Many configuration options (Ex: site_title, title_image) could either be # static (String), methods (Symbol) or procs (Proc). This wrapper takes care of # returning the content when String or using instance_eval when Symbol or Proc. # class StringSymbolOrProcSetting < DynamicSetting def value(context = self) case @setting when Symbol, Proc context.instance_eval(&@setting) else @setting end end end end
Version data entries
36 entries across 36 versions & 5 rubygems