class Shaf::Generator::Profile
Public Instance Methods
attributes()
click to toggle source
# File lib/shaf/generator/profile.rb, line 30 def attributes args[1..-1].map do |attr| name, type = attr.split(':') type ||= 'String' [name, type.capitalize] end end
call()
click to toggle source
# File lib/shaf/generator/profile.rb, line 7 def call create_profile end
create_profile()
click to toggle source
# File lib/shaf/generator/profile.rb, line 38 def create_profile content = render(template, opts) write_output(target, content) end
model_class_name()
click to toggle source
# File lib/shaf/generator/profile.rb, line 18 def model_class_name Utils::model_name(profile_name) end
opts()
click to toggle source
# File lib/shaf/generator/profile.rb, line 43 def opts { profile_name: profile_name, profile_class_name: "#{model_class_name}", attributes: attributes, } end
profile_name()
click to toggle source
# File lib/shaf/generator/profile.rb, line 11 def profile_name n = args.first || "" return n unless n.empty? raise Command::ArgumentError, "Please provide a profile name when using the profile generator!" end
target()
click to toggle source
# File lib/shaf/generator/profile.rb, line 26 def target "api/profiles/#{profile_name}.rb" end
template()
click to toggle source
# File lib/shaf/generator/profile.rb, line 22 def template 'api/profile.rb' end