Module: AbAdmin::Models::Track

Extended by:
ActiveSupport::Concern
Included in:
Track
Defined in:
lib/ab_admin/models/track.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#action_title(params = {}) ⇒ Object


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ab_admin/models/track.rb', line 35

def action_title(params = {})
  parts = key.split('.')
  lookups = []
  if parts.length == 2
    lookups << [parts[0], 'actions', parts[1], 'title']
    lookups << [parts[0], 'actions', parts[1]]
    lookups << ['actions', parts[1], 'title']
  else
    lookups << ['actions', key, 'title']
    lookups << ['actions', key]
  end
  lookups.map!{|l| l.join('.').to_sym }
  lookups << key

  I18n.t(lookups.shift, (parameters.merge(params) || {}).merge(scope: :admin, default: lookups))
end

#trackable_changed_attrsObject


52
53
54
55
# File 'lib/ab_admin/models/track.rb', line 52

def trackable_changed_attrs
  return unless trackable
  trackable_changes.keys.map { |attr| trackable_han(attr) }.join(', ')
end

#trackable_han(attr) ⇒ Object


57
58
59
60
# File 'lib/ab_admin/models/track.rb', line 57

def trackable_han(attr)
  attr_s = attr.to_s
  trackable.class.han attr_s =~ /_ids$/ ? attr_s.sub(/_ids$/, '').pluralize : attr_s
end