Sha256: 58139430c7b8efb1b53cac1193da13369e5abfdc230663d48074764828bae2e5

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 Bytes

Contents

require 'rails/generators/base'

module Grape
  module Generators
    module Transformations
      class InstallGenerator < Rails::Generators::Base

        source_root File.expand_path("../../templates", __FILE__)

        def copy_initializer
          template "grape-transformations.rb", "config/initializers/grape-transformations.rb"
        end

        def generate_layout
          create_file "app/api/#{app_name}/entities/.keep"
        end

        private

        # Returns the app name
        # @return [String]
        def app_name
          Rails.application.config.session_options[:key].sub(/^_/,'').sub(/_session/,'')
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-transformations-0.0.1 lib/grape/generators/transformations/install_generator.rb