Module: Validateable::ClassMethods
- Defined in:
- lib/validateable.rb
Instance Method Summary collapse
-
#human_attribute_name(attribute_key_name, options = {}) ⇒ Object
rubocop:todo Metrics/AbcSize.
- #human_name(options = {}) ⇒ Object
- #self_and_descendants_from_active_record ⇒ Object
Instance Method Details
#human_attribute_name(attribute_key_name, options = {}) ⇒ Object
rubocop:todo Metrics/AbcSize
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/validateable.rb', line 24 def human_attribute_name(attribute_key_name, = {}) # rubocop:todo Metrics/AbcSize defaults = self_and_descendants_from_active_record.map do |klass| "#{klass.name.underscore}.#{attribute_key_name}" \ "#{klass.name.underscore}.#{attribute_key_name}" end defaults << [:default] if [:default] defaults.flatten! defaults << attribute_key_name.to_s.humanize [:count] ||= 1 I18n.t(defaults.shift, **.merge(default: defaults, scope: %i[activerecord attributes])) end |
#human_name(options = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/validateable.rb', line 37 def human_name( = {}) defaults = self_and_descendants_from_active_record.map do |klass| "#{klass.name.underscore}" \ "#{klass.name.underscore}" end defaults << name.humanize I18n.t(defaults.shift, { scope: %i[activerecord models], count: 1, default: defaults }.merge()) end |
#self_and_descendants_from_active_record ⇒ Object
20 21 22 |
# File 'lib/validateable.rb', line 20 def self_and_descendants_from_active_record [self] end |