Sha256: 19972b28154067fee56fc8e5755c906b7f49d464966169239c54341f9b36c540

Contents?: true

Size: 676 Bytes

Versions: 1

Compression:

Stored size: 676 Bytes

Contents

require 'active_support/concern'

module Nrb
  module Commands
    module ResourceGenerator
      extend ActiveSupport::Concern

      included do
        argument :resource, type: :string, required: true,
          desc:   'resource type',
          banner: 'resource',
          enum:   Nrb.config.resources.map(&:singularize)

        argument :name, type: :string, required: true,
          desc:   'name of the resource',
          banner: 'name'
      end

      private

      def target(final = nil)
        File.join(File.expand_path(resource.pluralize), final.to_s)
      end

      def valid_resources
        self.class.valid_resources
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nrb-1.1.0 lib/nrb/commands/concerns/resource_generator.rb