Sha256: da5495265835fdc1474050479d81d5dc60fe338e8fdc31c04f85f2771783aa55

Contents?: true

Size: 650 Bytes

Versions: 1

Compression:

Stored size: 650 Bytes

Contents

require 'rails/generators'
module Reactrb
  class Component < Rails::Generators::Base
    source_root File.expand_path('../templates', __FILE__)

    argument :components, type: :array
    def create_component_file
      self.components.each do |component|
        component_array = component.split('::')
        @modules = component_array[0..-2]
        @file_name = component_array.last
        @indet = 1
        template 'component_template.rb',
                 File.join('app/views/components',
                           @modules.map(&:downcase).join('/'),
                           "#{@file_name.underscore}.rb")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reactrb-rails-generator-0.2.0 lib/generators/reactrb/component_generator.rb