Sha256: 8ee9a0c1bd7db4d165dec797f529ff6d724ddd672d54d42c4bc6a8b28e40ffd1

Contents?: true

Size: 514 Bytes

Versions: 1

Compression:

Stored size: 514 Bytes

Contents

module Nrb
  module Commands
    class Resource < Commands::Inside
      include ResourceGenerator

      def self.valid_resources
        arguments.find { |a| a.name == 'resource' }.enum
      end

      def ensure_valid_resource
        return true if valid_resources.include? resource
        fail_invalid_resource
      end

      private

      def fail_invalid_resource
        fail Nrb::InvalidResourceError,
          "<resource> must be one of: #{valid_resources.join(', ')}."
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nrb-1.1.0 lib/nrb/commands/base/resource.rb