Sha256: 26e55ff9bd06dd56a8337aa123a1531360cfa0b31ed3120aa8d2fc3aeb99c8b8

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

module Ellen
  class Env
    module Validatable
      extend ActiveSupport::Concern

      module ClassMethods
        def envs
          @envs ||= []
        end

        def env(key, description, options = {})
          envs << Env.new(key, description, options)
        end

        def usage
          envs.map(&:to_usage).join("\n")
        end
      end

      def validate
        self.class.envs.each(&:validate)
      rescue MissingRequiredKeyError => exception
        Ellen.die("#{exception}\n#{self.class.usage}")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ellen-0.1.1 lib/ellen/env/validatable.rb