module Invitation::Generators::Helpers
Private Instance Methods
class_path()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 42 def class_path @class_path end
file_path()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 15 def file_path model_name.underscore end
invitable_file_path(invitable_class_name)
click to toggle source
# File lib/generators/invitation/helpers.rb, line 60 def invitable_file_path(invitable_class_name) File.join('app', 'models', "#{invitable_model_name(invitable_class_name).underscore}.rb") end
invitable_model_name(invitable_class_name)
click to toggle source
# File lib/generators/invitation/helpers.rb, line 64 def invitable_model_name(invitable_class_name) if namespaced? [namespace.to_s] + [invitable_class_name.classify] else [invitable_class_name.classify] end.join('::') end
migration_version()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 76 def migration_version if rails5_and_up? "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]" end end
model_class_name()
click to toggle source
Either return the model passed in a classified form or return the default “User”.
# File lib/generators/invitation/helpers.rb, line 7 def model_class_name options[:model] ? options[:model].classify : 'User' end
model_name()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 27 def model_name if namespaced? [namespace.to_s] + [model_class_name] else [model_class_name] end.join('::') end
model_path()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 11 def model_path @model_path ||= File.join('app', 'models', "#{file_path}.rb") end
namespace()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 19 def namespace Rails::Generators.namespace if Rails::Generators.respond_to?(:namespace) end
namespaced?()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 23 def namespaced? !namespace.nil? end
plural_name()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 50 def plural_name singular_name.pluralize end
rails5_and_up?()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 72 def rails5_and_up? Rails::VERSION::MAJOR >= 5 end
singular_name()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 46 def singular_name @file_name end
table_name()
click to toggle source
# File lib/generators/invitation/helpers.rb, line 35 def table_name @table_name ||= begin base = plural_name (class_path + [base]).join('_') end end