Sha256: 675bcc3f42391cd7fc4b7f42ff4241b80b18a0f8e712666ca855fca92a0e288a
Contents?: true
Size: 1.79 KB
Versions: 4
Compression:
Stored size: 1.79 KB
Contents
module Invitation module Generators module Helpers private # Either return the model passed in a classified form or return the default "User". def model_class_name options[:model] ? options[:model].classify : 'User' end def model_path @model_path ||= File.join('app', 'models', "#{file_path}.rb") end def file_path model_name.underscore end def namespace Rails::Generators.namespace if Rails::Generators.respond_to?(:namespace) end def namespaced? !namespace.nil? end def model_name if namespaced? [namespace.to_s] + [model_class_name] else [model_class_name] end.join('::') end def table_name @table_name ||= begin base = plural_name (class_path + [base]).join('_') end end def class_path @class_path end def singular_name @file_name end def plural_name singular_name.pluralize end def assign_names!(name) #:nodoc: @class_path = name.include?('/') ? name.split('/') : name.split('::') @class_path.map!(&:underscore) @file_name = @class_path.pop end def invitable_file_path(invitable_class_name) File.join('app', 'models', "#{invitable_model_name(invitable_class_name).underscore}.rb") end def invitable_model_name(invitable_class_name) if namespaced? [namespace.to_s] + [invitable_class_name.classify] else [invitable_class_name.classify] end.join('::') end def migration_version if Rails.version.start_with? '5' "[#{ActiveRecord::Migration.current_version}]" end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems