class Opalla::ComponentGenerator

Public Instance Methods

create_component() click to toggle source
# File lib/rails/generators/opalla/component_generator.rb, line 5
    def create_component
      create_file js("components/#{file_name}_component.rb"), <<~CONTROLLER
        class #{class_name}Component < ApplicationComponent
          # Feel free to write your component actions, bindings, events
        end
      CONTROLLER
    end
create_views() click to toggle source
# File lib/rails/generators/opalla/component_generator.rb, line 13
    def create_views
      ext = defined?(Haml) ? 'haml' : 'erb'
      create_file js("views/components/_#{file_name}.#{ext}"), <<~VIEW
      .#{file_name.dasherize}
        -# Component content
      VIEW
    end

Protected Instance Methods

js(path) click to toggle source
# File lib/rails/generators/opalla/component_generator.rb, line 23
def js(path)
  "app/assets/javascripts/#{path}"
end