class ActiveScaffold::Config::Base
Constants
- NO_FORMATS
Attributes
action_group[RW]
action_group
this action should belong to
core[R]
formats[W]
user_settings_key[R]
Public Class Methods
inherited(subclass)
click to toggle source
# File lib/active_scaffold/config/base.rb, line 22 def self.inherited(subclass) 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
new(core_config)
click to toggle 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
columns_accessor(*names, &block)
click to toggle source
# File lib/active_scaffold/config/base.rb, line 194 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 if self::UserSettings == ActiveScaffold::Config::Base::UserSettings const_set 'UserSettings', Class.new(ActiveScaffold::Config::Base::UserSettings) end var = "@#{name}" self::UserSettings.class_eval do define_method "#{name}=" do |val| instance_variable_set var, proxy_columns(build_action_columns(val)) end define_method name do instance_variable_get(var) || instance_variable_set(var, proxy_columns(@conf.send(name))) end end end end
columns_reader(name, options, &block)
click to toggle source
# File lib/active_scaffold/config/base.rb, line 176 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
columns_writer(name)
click to toggle source
# File lib/active_scaffold/config/base.rb, line 164 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
crud_type()
click to toggle source
delegate
# File lib/active_scaffold/config/base.rb, line 38 def crud_type self.class.crud_type end
formats()
click to toggle source
# File lib/active_scaffold/config/base.rb, line 69 def formats return @formats || NO_FORMATS if frozen? @formats ||= NO_FORMATS.dup end
label(model = nil)
click to toggle source
# File lib/active_scaffold/config/base.rb, line 42 def label(model = nil) model ||= @core.label(:count => 1) @label.nil? ? model : as_(@label, :model => model) end
model_id()
click to toggle source
# File lib/active_scaffold/config/base.rb, line 47 def model_id (core || self).model_id end
new_user_settings(storage, params)
click to toggle source
# File lib/active_scaffold/config/base.rb, line 58 def new_user_settings(storage, params) ActiveScaffold::Registry.user_settings[user_settings_key] = self.class::UserSettings.new(self, storage, params) end
setup_user_setting_key()
click to toggle 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
user()
click to toggle source
the user property gets set to the instantiation of the local UserSettings
class during the automatic instantiation of this class.
# File lib/active_scaffold/config/base.rb, line 54 def user ActiveScaffold::Registry.user_settings[user_settings_key] end
Private Instance Methods
build_action_columns(val)
click to toggle source
# File lib/active_scaffold/config/base.rb, line 158 def build_action_columns(val) @core.build_action_columns self, val end