class ActiveScaffold::Config::Base
Constants
- NO_FORMATS
Attributes
action_group
this action should belong to
Public Class Methods
Source
# File lib/active_scaffold/config/base.rb, line 133 def self.inherited(subclass) super subclass.const_set :UserSettings, Class.new(subclass.superclass::UserSettings) class << subclass # the crud type of the action. possible values are :create, :read, :update, :delete, and nil. # this is not a setting for the developer. it's self-description for the actions. attr_reader :crud_type protected def crud_type=(val) raise ArgumentError, "unknown CRUD type #{val}" unless %i[create read update delete].include?(val.to_sym) @crud_type = val.to_sym end end end
Calls superclass method
Source
# File lib/active_scaffold/config/base.rb, line 7 def initialize(core_config) @core = core_config @action_group = self.class.action_group.clone if self.class.action_group # start with the ActionLink defined globally @link = self.class.link.clone if self.class.respond_to?(:link) && self.class.link setup_user_setting_key end
Private Class Methods
Source
# File lib/active_scaffold/config/base.rb, line 189 def self.columns_accessor(*names, &block) options = names.extract_options! self.columns_collections = ((columns_collections || []) + names).uniq names.each do |name| columns_writer name columns_reader name, options, &block unless method_defined? name var = :"@#{name}" self::UserSettings.class_eval do define_method :"#{name}=" do |val| instance_variable_set var, build_action_columns(val) end define_method name do instance_variable_get(var) || @conf.send(name) end define_method :"override_#{name}" do |&blck| send(:"#{name}=", send(name)).tap { |cols| blck&.call cols } end end end end
Source
# File lib/active_scaffold/config/base.rb, line 171 def self.columns_reader(name, options, &block) var = :"@#{name}" define_method name do unless instance_variable_defined?(var) # lazy evaluation action, columns = options[:copy] if options[:copy] if action && @core.actions.include?(action) action_columns = @core.send(action).send(columns || :columns).clone action_columns.action = self instance_variable_set(var, action_columns) else send(:"#{name}=", @core.columns._inheritable) end instance_exec(&block) if block end instance_variable_get(var) end end
Source
# File lib/active_scaffold/config/base.rb, line 159 def self.columns_writer(name) var = :"@#{name}" define_method :"#{name}=" do |val| if instance_variable_defined?(var) instance_variable_get(var).set_values(*val) instance_variable_get(var) else instance_variable_set(var, build_action_columns(val)) end end end
Public Instance Methods
Source
# File lib/active_scaffold/config/base.rb, line 23 def crud_type self.class.crud_type end
delegate
Source
# File lib/active_scaffold/config/base.rb, line 52 def formats return @formats || NO_FORMATS if frozen? @formats ||= NO_FORMATS.dup end
Source
# File lib/active_scaffold/config/base.rb, line 27 def label(model = nil) model ||= @core.label(count: 1) @label.nil? ? model : as_(@label, model: model) end
Source
# File lib/active_scaffold/config/base.rb, line 32 def model_id (core || self).model_id end
Source
# File lib/active_scaffold/config/base.rb, line 41 def new_user_settings(storage, params) ActiveScaffold::Registry.user_settings[user_settings_key] = self.class::UserSettings.new(self, storage, params) end
Source
# File lib/active_scaffold/config/base.rb, line 16 def setup_user_setting_key @user_settings_key = :"#{model_id}_#{self.class.name.underscore}" end
Source
# File lib/active_scaffold/config/base.rb, line 37 def user ActiveScaffold::Registry.user_settings[user_settings_key] end
the user property gets set to the instantiation of the local UserSettings
class during the automatic instantiation of this class.
Private Instance Methods
Source
# File lib/active_scaffold/config/base.rb, line 153 def build_action_columns(val) @core.build_action_columns self, val end