Class: ActiveAdmin::Resource::Name

Inherits:
ActiveModel::Name
  • Object
show all
Defined in:
lib/active_admin/resource/naming.rb

Overview

A subclass of ActiveModel::Name which supports the different APIs presented in Rails < 3.1 and > 3.1.

Defined Under Namespace

Classes: StringClassProxy, StringProxy

Instance Method Summary collapse

Constructor Details

#initialize(klass, name = nil) ⇒ Name

Returns a new instance of Name.



35
36
37
38
39
40
41
# File 'lib/active_admin/resource/naming.rb', line 35

def initialize(klass, name = nil)
  if ActiveModel::Name.instance_method(:initialize).arity == 1
    super(proxy_for_initializer(klass, name))
  else
    super(klass, nil, name)
  end
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/active_admin/resource/naming.rb', line 58

def eql?(other)
  to_str.eql?(other.to_str)
end

#proxy_for_initializer(klass, name) ⇒ Object



47
48
49
50
51
52
# File 'lib/active_admin/resource/naming.rb', line 47

def proxy_for_initializer(klass, name)
  return klass unless name
  return StringClassProxy.new(klass, name) if klass

  StringProxy.new(name)
end

#route_keyObject



54
55
56
# File 'lib/active_admin/resource/naming.rb', line 54

def route_key
  plural
end

#translate(options = {}) ⇒ Object



43
44
45
# File 'lib/active_admin/resource/naming.rb', line 43

def translate(options = {})
  I18n.t i18n_key, {scope: [:activerecord, :models]}.merge(options)
end