Sha256: 7490357ce2ce735fc539226703acf2d9a1dcaef2cfb30aefeba162e38611ea55

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

require_relative "../context"
require_relative "../constants"

module Hanami
  module CLI
    module Generators
      module App
        # @since 2.0.0
        # @api private
        class SliceContext < Generators::Context
          # @since 2.0.0
          # @api private
          def initialize(inflector, app, slice, url, **options)
            @slice = slice
            @url = url
            super(inflector, app, **options)
          end

          # @since 2.0.0
          # @api private
          def camelized_slice_name
            inflector.camelize(slice)
          end

          # @since 2.0.0
          # @api private
          def underscored_slice_name
            inflector.underscore(slice)
          end

          # @since 2.1.0
          # @api private
          def humanized_slice_name
            inflector.humanize(slice)
          end

          # @since 2.1.0
          # @api private
          def stylesheet_erb_tag
            %(<%= stylesheet_tag "app" %>)
          end

          # @since 2.1.0
          # @api private
          def javascript_erb_tag
            %(<%= javascript_tag "app" %>)
          end

          # @since 2.2.0
          # @api private
          def generate_db?
            !options.fetch(:skip_db, false)
          end

          # @since 2.2.0
          # @api private
          def generate_route?
            !options.fetch(:skip_route, false)
          end

          private

          attr_reader :slice

          attr_reader :url
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hanami-cli-2.2.1 lib/hanami/cli/generators/app/slice_context.rb
hanami-cli-2.2.0 lib/hanami/cli/generators/app/slice_context.rb
hanami-cli-2.2.0.rc1 lib/hanami/cli/generators/app/slice_context.rb