Sha256: dd3b22b6c65030ef8c04aebfc1006c53092080ae4e2402c97fc91aab0c3a5565

Contents?: true

Size: 644 Bytes

Versions: 5

Compression:

Stored size: 644 Bytes

Contents

require "rails/generators"

module ActiveRecord
  # Generate SyncMachine files for ActiveRecord.
  class SyncMachineGenerator < Rails::Generators::NamedBase
    class_option :subject, type: :string
    source_root File.expand_path('templates', __dir__)

    def create_payload_file
      template "payload.rb", "app/models/#{file_path}/payload.rb"
    end

    def create_payload_migration
      generate(
        "migration",
        "create_#{singular_name}_payloads body:text generated_at:datetime subject_id:integer"
      )
    end

    private

    def subject
      options['subject'] || file_name.split(/_to_/).first
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sync_machine-1.4.0 lib/rails/generators/active_record/sync_machine_generator.rb
sync_machine-1.3.0 lib/rails/generators/active_record/sync_machine_generator.rb
sync_machine-1.2.0 lib/rails/generators/active_record/sync_machine_generator.rb
sync_machine-1.1.1 lib/rails/generators/active_record/sync_machine_generator.rb
sync_machine-1.1.0 lib/rails/generators/active_record/sync_machine_generator.rb