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
-
#crud_type ⇒ Object
delegate.
-
#initialize(core_config) ⇒ Base
constructor
A new instance of Base.
- #label(model = nil) ⇒ 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.
7 8 9 10 11 12 13 14 |
# 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 |
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
52 53 54 |
# File 'lib/active_scaffold/config/base.rb', line 52 def action_group @action_group end |
#core ⇒ Object (readonly)
Returns the value of attribute core.
20 21 22 |
# File 'lib/active_scaffold/config/base.rb', line 20 def core @core end |
#formats ⇒ Object
54 55 56 57 |
# File 'lib/active_scaffold/config/base.rb', line 54 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.
36 37 38 |
# File 'lib/active_scaffold/config/base.rb', line 36 def user_settings_key @user_settings_key end |
Class Method Details
.inherited(subclass) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/active_scaffold/config/base.rb', line 141 def self.inherited(subclass) 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
#crud_type ⇒ Object
delegate
23 24 25 |
# File 'lib/active_scaffold/config/base.rb', line 23 def crud_type self.class.crud_type end |
#label(model = nil) ⇒ Object
27 28 29 30 |
# 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 |
#model_id ⇒ Object
32 33 34 |
# File 'lib/active_scaffold/config/base.rb', line 32 def model_id (core || self).model_id end |
#new_user_settings(storage, params) ⇒ Object
43 44 45 |
# File 'lib/active_scaffold/config/base.rb', line 43 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
16 17 18 |
# 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 ⇒ Object
the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
39 40 41 |
# File 'lib/active_scaffold/config/base.rb', line 39 def user ActiveScaffold::Registry.user_settings[user_settings_key] end |