Class: ActiveScaffold::Config::Nested
- Defined in:
- lib/active_scaffold/config/nested.rb
Constant Summary collapse
- @@shallow_delete =
true
Constants inherited from Base
Instance Attribute Summary collapse
-
#ignore_order_from_association ⇒ Object
Returns the value of attribute ignore_order_from_association.
-
#label ⇒ Object
writeonly
the label for this Nested action.
-
#shallow_delete ⇒ Object
instance-level configuration —————————-.
Attributes inherited from Base
#action_group, #core, #formats, #user_settings_key
Instance Method Summary collapse
-
#add_link(attribute, options = {}) ⇒ Object
Add a nested ActionLink.
-
#add_new_link(attribute, options = {}) ⇒ Object
Add a nested ActionLink to new action.
- #add_scoped_link(named_scope, options = {}) ⇒ Object
-
#initialize(core_config) ⇒ Nested
constructor
A new instance of Nested.
Methods inherited from Base
inherited, #label, #model_id, #new_user_settings, #setup_user_setting_key, #user
Methods included from ActiveScaffold::Configurable
#configure, #method_missing, #respond_to_missing?
Constructor Details
#initialize(core_config) ⇒ Nested
Returns a new instance of Nested.
7 8 9 10 11 12 |
# File 'lib/active_scaffold/config/nested.rb', line 7 def initialize(core_config) super @label = :add_existing_model @shallow_delete = self.class.shallow_delete @ignore_order_from_association = self.class.ignore_order_from_association end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveScaffold::Configurable
Instance Attribute Details
#ignore_order_from_association ⇒ Object
Returns the value of attribute ignore_order_from_association.
25 26 27 |
# File 'lib/active_scaffold/config/nested.rb', line 25 def ignore_order_from_association @ignore_order_from_association end |
#label=(value) ⇒ Object (writeonly)
the label for this Nested action. used for the header.
78 79 80 |
# File 'lib/active_scaffold/config/nested.rb', line 78 def label=(value) @label = value end |
#shallow_delete ⇒ Object
instance-level configuration
23 24 25 |
# File 'lib/active_scaffold/config/nested.rb', line 23 def shallow_delete @shallow_delete end |
Instance Method Details
#add_link(attribute, options = {}) ⇒ Object
Add a nested ActionLink
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/active_scaffold/config/nested.rb', line 28 def add_link(attribute, = {}) column = @core.columns[attribute.to_sym] raise ArgumentError, "unknown column #{attribute}" if column.nil? raise ArgumentError, "column #{attribute} is not an association" if column.association.nil? label = if column.association.polymorphic? column.label else column.association.klass.model_name.human(count: column.association.singular? ? 1 : 2, default: column.association.klass.name.pluralize) end .reverse_merge! security_method: :nested_authorized?, label: label action_group = .delete(:action_group) || self.action_group action_link = @core.link_for_association(column, ) @core.action_links.add_to_group(action_link, action_group) unless action_link.nil? action_link end |
#add_new_link(attribute, options = {}) ⇒ Object
Add a nested ActionLink to new action
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/active_scaffold/config/nested.rb', line 47 def add_new_link(attribute, = {}) column = @core.columns[attribute.to_sym] raise ArgumentError, "unknown column #{attribute}" if column.nil? raise ArgumentError, "column #{attribute} is not an association" if column.association.nil? model = if column.association.polymorphic? column.label else column.association.klass.model_name.human(count: 1) end .reverse_merge!( security_method: :nested_authorized?, label: as_(:add_model, model: model), action: 'new', refresh_on_close: false, parameters: {parent_controller: @core.controller_path} ) action_group = .delete(:action_group) || self.action_group action_link = @core.link_for_association(column, ) @core.action_links.add_to_group(action_link, action_group) unless action_link.nil? action_link end |
#add_scoped_link(named_scope, options = {}) ⇒ Object
71 72 73 74 75 |
# File 'lib/active_scaffold/config/nested.rb', line 71 def add_scoped_link(named_scope, = {}) action_link = @core.link_for_association_as_scope(named_scope.to_sym, ) action_group = .delete(:action_group) || self.action_group @core.action_links.add_to_group(action_link, action_group) unless action_link.nil? end |