Module: Fustrate::Rails::Concerns::Model::ClassMethods
- Defined in:
- lib/fustrate/rails/concerns/model.rb
Instance Method Summary collapse
- #build_from_params(permitted_params, **attributes) ⇒ Object
-
#human_name(new_name = nil) ⇒ Object
Allow models to define a more reasonable name, usually used to remove a module/namespace.
Instance Method Details
#build_from_params(permitted_params, **attributes) ⇒ Object
20 21 22 23 24 |
# File 'lib/fustrate/rails/concerns/model.rb', line 20 def build_from_params(permitted_params, **attributes) key = attributes.delete(:params_key) new(**attributes) { _1.assign_params(permitted_params, key:) } end |
#human_name(new_name = nil) ⇒ Object
Allow models to define a more reasonable name, usually used to remove a module/namespace.
14 15 16 17 18 |
# File 'lib/fustrate/rails/concerns/model.rb', line 14 def human_name(new_name = nil) @human_name = new_name.to_s if new_name @human_name ||= to_s.underscore.gsub(%r{\A.*/}, '') end |