Module: ConsoleUpdate::ClassMethods
- Defined in:
- lib/console_update.rb
Instance Method Summary collapse
-
#can_console_update(options = {}) ⇒ Object
Enable a model to be updated via the console and an editor.
Instance Method Details
#can_console_update(options = {}) ⇒ Object
Enable a model to be updated via the console and an editor. By default editable attributes are columns with text, boolean or integer-like values.
Options:
- :only
-
Sets these attributes as the default editable attributes.
- :except
-
Sets the default editable attributes as normal except for these attributes.
- :editor
-
Overrides global editor for just this model.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/console_update.rb', line 21 def can_console_update(={}) cattr_accessor :console_editor self.console_editor = [:editor] || ConsoleUpdate.editor cattr_accessor :default_editable_attributes if [:only] self.default_editable_attributes = [:only] elsif [:except] self.default_editable_attributes = self.column_names.select {|e| ![:except].include?(e) } else self.default_editable_attributes = get_default_editable_attributes end extend SingletonMethods send :include, InstanceMethods end |