Sha256: 9c124d9b9ad0ace68852f036791bb4685d37a07b7553a682472c55ac5b838ba5

Contents?: true

Size: 582 Bytes

Versions: 4

Compression:

Stored size: 582 Bytes

Contents

require 'generators/rom'

module ROM
  module Generators
    class RelationGenerator < Base
      class_option :adapter,
        banner: "--adapter=adapter",
        desc: "specify an adapter to use", required: true,
        default: ROM.adapters.keys.first

      def create_relation_file
        template(
          'relation.rb.erb',
          File.join('app', 'relations', "#{file_name}_relation.rb")
        )
      end

      private

      def dataset
        class_name.underscore.pluralize
      end

      def adapter
        options[:adapter]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rom-rails-0.3.1 lib/generators/rom/relation_generator.rb
rom-rails-0.3.0 lib/generators/rom/relation_generator.rb
rom-rails-0.3.0.rc1 lib/generators/rom/relation_generator.rb
rom-rails-0.3.0.beta1 lib/generators/rom/relation_generator.rb