Module: Pu::Profile::Concerns::ProfileArguments

Extended by:
ActiveSupport::Concern
Included in:
InstallGenerator, SetupGenerator
Defined in:
lib/generators/pu/profile/concerns/profile_arguments.rb

Instance Method Summary collapse

Instance Method Details

#normalize_argumentsObject

Normalize arguments: if name is omitted, default to “UserModelProfile”; if name looks like an attribute (contains “:”), treat it as an attribute and still default the profile name to “UserModelProfile”.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/pu/profile/concerns/profile_arguments.rb', line 17

def normalize_arguments
  default_name = "#{options[:user_model] || "User"}Profile"
  if name.nil?
    @profile_name = default_name
    @profile_attributes = attributes
  elsif name.include?(":")
    @profile_attributes = [name, *attributes]
    @profile_name = default_name
  else
    @profile_name = name
    @profile_attributes = attributes
  end
end