Sha256: dd8243740850d91d572d9a65d61a21ecf5737ebcdd8e2a599251f46aebb25d94

Contents?: true

Size: 543 Bytes

Versions: 2

Compression:

Stored size: 543 Bytes

Contents

require "rails/generators"

module Mongoid
  # Generate SyncMachine files for Mongoid.
  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_sync_file
      template "sync.rb", "app/services/#{file_path}.rb"
    end

    private

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sync_machine_generator-0.8.0 lib/generators/mongoid/sync_machine_generator.rb
sync_machine_generator-0.1.0 lib/generators/mongoid/sync_machine_generator.rb