Class: ActiveScaffold::Config::Base
- Extended by:
- ActiveScaffold::Configurable
- Includes:
- ActiveScaffold::Configurable
- Defined in:
- lib/active_scaffold/config/base.rb
Direct Known Subclasses
Core, Delete, DeletedRecords, FieldSearch, Form, List, Mark, Nested, Search, Show, Subform
Defined Under Namespace
Classes: UserSettings
Constant Summary collapse
- NO_FORMATS =
[].freeze
Instance Attribute Summary collapse
-
#action_group ⇒ Object
action_group this action should belong to.
-
#core ⇒ Object
readonly
Returns the value of attribute core.
- #formats ⇒ Object
-
#user_settings_key ⇒ Object
readonly
Returns the value of attribute user_settings_key.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(core_config) ⇒ Base
constructor
A new instance of Base.
- #label(model = nil, core: @core) ⇒ Object
- #model_id ⇒ Object
- #new_user_settings(storage, params) ⇒ Object
- #setup_user_setting_key ⇒ Object
-
#user ⇒ Object
the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
Methods included from ActiveScaffold::Configurable
configure, method_missing, respond_to_missing?
Constructor Details
#initialize(core_config) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 16 17 |
# File 'lib/active_scaffold/config/base.rb', line 10 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveScaffold::Configurable
Instance Attribute Details
#action_group ⇒ Object
action_group this action should belong to
51 52 53 |
# File 'lib/active_scaffold/config/base.rb', line 51 def action_group @action_group end |
#core ⇒ Object (readonly)
Returns the value of attribute core.
23 24 25 |
# File 'lib/active_scaffold/config/base.rb', line 23 def core @core end |
#formats ⇒ Object
53 54 55 56 57 |
# File 'lib/active_scaffold/config/base.rb', line 53 def formats return @formats || NO_FORMATS if frozen? @formats ||= NO_FORMATS.dup end |
#user_settings_key ⇒ Object (readonly)
Returns the value of attribute user_settings_key.
23 24 25 |
# File 'lib/active_scaffold/config/base.rb', line 23 def user_settings_key @user_settings_key end |
Class Method Details
.inherited(subclass) ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/active_scaffold/config/base.rb', line 138 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 |
Instance Method Details
#label(model = nil, core: @core) ⇒ Object
28 29 30 31 |
# File 'lib/active_scaffold/config/base.rb', line 28 def label(model = nil, core: @core) model ||= core.label(count: 1) @label.nil? ? model : as_(@label, model: model) end |
#model_id ⇒ Object
33 34 35 |
# File 'lib/active_scaffold/config/base.rb', line 33 def model_id (core || self).model_id end |
#new_user_settings(storage, params) ⇒ Object
42 43 44 |
# File 'lib/active_scaffold/config/base.rb', line 42 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 ⇒ Object
19 20 21 |
# File 'lib/active_scaffold/config/base.rb', line 19 def setup_user_setting_key @user_settings_key = :"#{model_id}_#{self.class.name.underscore}" end |
#user ⇒ Object
the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
38 39 40 |
# File 'lib/active_scaffold/config/base.rb', line 38 def user ActiveScaffold::Registry.user_settings[user_settings_key] end |