Sha256: 8bb8f35a2fbe821b490bd104052c4d53f56943bcd30d6184595001f97985c981
Contents?: true
Size: 1.06 KB
Versions: 2
Compression:
Stored size: 1.06 KB
Contents
module Statesman module GeneratorHelpers def class_name_option ", class_name: '#{parent}'" unless parent.underscore == parent_name end def model_file_name "app/models/#{klass.underscore}.rb" end def migration_class_name klass.gsub(/::/, '').pluralize end def next_migration_number Time.now.utc.strftime("%Y%m%d%H%M%S") end def parent_name parent.demodulize.underscore end def parent_table_name parent.demodulize.underscore.pluralize end def parent_id parent_name + "_id" end def table_name klass.demodulize.underscore.pluralize end def index_name(index_id) "index_#{table_name}_#{index_id}" end def mysql? ActiveRecord::Base.configurations[Rails.env]. try(:[], "adapter").try(:match, /mysql/) end def database_supports_partial_indexes? Statesman::Adapters::ActiveRecord.database_supports_partial_indexes? end def metadata_default_value Utils.rails_5_or_higher? ? "{}" : "{}".inspect end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
statesman-3.2.0 | lib/generators/statesman/generator_helpers.rb |
statesman-3.1.0 | lib/generators/statesman/generator_helpers.rb |