Module: Bp3::Core::Displayable
Instance Method Summary collapse
- #admin_display_name ⇒ Object
- #display_name ⇒ Object
- #filter ⇒ Object private
- #filter_attributes ⇒ Object private
- #filter_object_fields ⇒ Object private
- #filtered_attributes ⇒ Object
- #i18n_key ⇒ Object
- #mark_changes_as_filtered(key) ⇒ Object private
- #to_dom_id ⇒ Object
- #version_filter_mask ⇒ Object private
Instance Method Details
#admin_display_name ⇒ Object
19 20 21 |
# File 'lib/bp3/core/displayable.rb', line 19 def admin_display_name "#{self.class.name.split('::').last} #{id}" end |
#display_name ⇒ Object
15 16 17 |
# File 'lib/bp3/core/displayable.rb', line 15 def display_name admin_display_name end |
#filter ⇒ Object (private)
56 57 58 59 60 61 |
# File 'lib/bp3/core/displayable.rb', line 56 def filter return @filter if @filter filters = Rails.application.config.filter_parameters @filter = ActiveSupport::ParameterFilter.new(filters, mask: version_filter_mask) end |
#filter_attributes ⇒ Object (private)
38 39 40 |
# File 'lib/bp3/core/displayable.rb', line 38 def filter_attributes filter.filter(attributes) end |
#filter_object_fields ⇒ Object (private)
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bp3/core/displayable.rb', line 42 def filter_object_fields self.object = filter.filter(object) if object.present? return if object_changes.blank? filtered_object_changes = filter.filter(object_changes) filtered_object_changes.each_key do |key| if filtered_object_changes[key] == version_filter_mask filtered_object_changes[key] = mark_changes_as_filtered(key) end end self.object_changes = filtered_object_changes end |
#filtered_attributes ⇒ Object
23 24 25 26 |
# File 'lib/bp3/core/displayable.rb', line 23 def filtered_attributes filter_object_fields if respond_to?(:object) filter_attributes end |
#i18n_key ⇒ Object
28 29 30 |
# File 'lib/bp3/core/displayable.rb', line 28 def i18n_key self.class.i18n_key end |
#mark_changes_as_filtered(key) ⇒ Object (private)
63 64 65 66 67 68 |
# File 'lib/bp3/core/displayable.rb', line 63 def mark_changes_as_filtered(key) change = object_changes[key] change[0] = version_filter_mask if change[0].present? change[1] = version_filter_mask if change[1].present? change end |
#to_dom_id ⇒ Object
11 12 13 |
# File 'lib/bp3/core/displayable.rb', line 11 def to_dom_id ActionView::RecordIdentifier.dom_id(self) end |
#version_filter_mask ⇒ Object (private)
34 35 36 |
# File 'lib/bp3/core/displayable.rb', line 34 def version_filter_mask '[FILTERED][DC]' end |