Module: UtopiaData::Resource::Naming

Included in:
UtopiaData::Resource
Defined in:
lib/utopia_data/resource/naming.rb

Instance Method Summary collapse

Instance Method Details

#plural_resource_labelObject



48
49
50
51
52
53
54
# File 'lib/utopia_data/resource/naming.rb', line 48

def plural_resource_label
  if @options[:as]
    @options[:as].pluralize
  else
    resource_name.human(:count => 3, :default => resource_label.pluralize).titleize
  end
end

#resource_labelObject

Returns the name to call this resource such as “Bank Account”



40
41
42
43
44
45
46
# File 'lib/utopia_data/resource/naming.rb', line 40

def resource_label
   if @options[:as]
     @options[:as]
   else
    resource_name.human(:default => resource_name.gsub('::', ' ')).titleize
  end
end

#resource_nameObject

Returns a name used to uniquely identify this resource this should be an instance of ActiveAdmin:Resource::Name, which responds to #singular, #plural, #route_key, #human etc.



30
31
32
33
34
35
36
37
# File 'lib/utopia_data/resource/naming.rb', line 30

def resource_name
  custom_name = @options[:as] && @options[:as].gsub(/\s/,'')
  @resource_name ||= if custom_name || !resource_class.respond_to?(:model_name)
    Resource::Name.new(resource_class, custom_name)
  else
    Resource::Name.new(resource_class)
  end
end