Sha256: 93c371972febca10b0bce804e34772c476ab9b1afd272362b454c9f733483828

Contents?: true

Size: 685 Bytes

Versions: 6

Compression:

Stored size: 685 Bytes

Contents

module Schema
  module Generators
    class ControllerGenerator < Rails::Generators::NamedBase
      argument :actions, type: :array, banner: "action action"
      source_root File.expand_path("../templates", __FILE__)

      def create_schema_files
        actions.each do |act|
          self.action_name = act.to_s.underscore
          template "schema.yml.erb", File.join("app/schemas", class_path, file_name, "#{action_name}.yml")
        end
      end

      protected

      attr_accessor :action_name

      def model_name
        file_name.singularize
      end

      def schema_title
        "#{action_name.to_s.humanize} #{model_name.titleize}"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
json_schema_rails-0.2.1 lib/generators/schema/controller/controller_generator.rb
json_schema_rails-0.2.0 lib/generators/schema/controller/controller_generator.rb
json_schema_rails-0.1.0 lib/generators/schema/controller/controller_generator.rb
json_schema_rails-0.0.3 lib/generators/schema/controller/controller_generator.rb
json_schema_rails-0.0.2 lib/generators/schema/controller/controller_generator.rb
json_schema_rails-0.0.1 lib/generators/schema/controller/controller_generator.rb