Module: Bp3::Core::Displayable

Extended by:
ActiveSupport::Concern
Included in:
Test
Defined in:
lib/bp3/core/displayable.rb

Instance Method Summary collapse

Instance Method Details

#admin_display_nameObject



19
20
21
# File 'lib/bp3/core/displayable.rb', line 19

def admin_display_name
  "#{self.class.name.split('::').last} #{id}"
end

#display_nameObject



15
16
17
# File 'lib/bp3/core/displayable.rb', line 15

def display_name
  admin_display_name
end

#filterObject (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_attributesObject (private)



38
39
40
# File 'lib/bp3/core/displayable.rb', line 38

def filter_attributes
  filter.filter(attributes)
end

#filter_object_fieldsObject (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_attributesObject



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_keyObject



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_idObject



11
12
13
# File 'lib/bp3/core/displayable.rb', line 11

def to_dom_id
  ActionView::RecordIdentifier.dom_id(self)
end

#version_filter_maskObject (private)



34
35
36
# File 'lib/bp3/core/displayable.rb', line 34

def version_filter_mask
  '[FILTERED][DC]'
end