class ActiveRecord::Generators::ActiveModelSerializersPgGenerator

Public Instance Methods

write_migration() click to toggle source
# File lib/generators/active_record/active_model_serializers_pg_generator.rb, line 9
def write_migration
  migration_template "migration.rb", "#{migration_path}/ams_pg_create_dasherize_functions.rb"
end

Private Instance Methods

jsonb_dasherize() click to toggle source
# File lib/generators/active_record/active_model_serializers_pg_generator.rb, line 37
def jsonb_dasherize
  read_sql('jsonb_dasherize')
end
migration_exists?(table_name) click to toggle source
# File lib/generators/active_record/active_model_serializers_pg_generator.rb, line 19
def migration_exists?(table_name)
  Dir.glob("#{File.join destination_root, migration_path}/[0-9]*_*.rb").grep(/\d+_ams_pg_create_dasherize_functions.rb$/).first
end
migration_path() click to toggle source
# File lib/generators/active_record/active_model_serializers_pg_generator.rb, line 23
def migration_path
  if Rails.version >= '5.0.3'
    db_migrate_path
  else
    @migration_path ||= File.join "db", "migrate"
  end
end
migration_version() click to toggle source
# File lib/generators/active_record/active_model_serializers_pg_generator.rb, line 31
def migration_version
  if Rails.version.start_with? '5'
    "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
  end
end
read_sql(funcname) click to toggle source
# File lib/generators/active_record/active_model_serializers_pg_generator.rb, line 15
def read_sql(funcname)
  File.read(File.join(File.expand_path('../templates', __FILE__), "#{funcname}.sql"))
end