require 'virtus' class ENVied module Hashable def to_hash require 'rack/utils' ::Rack::Utils.parse_nested_query(self) end end module Arrayable def to_a self.split(/(? [:DATABASE_URL] # # @return [Array] the list of variable names def self.required_variable_names required_variables.map(&:name).map(&:to_sym) end def self.required_variables from_required_group = ->(var){ self.required_groups.include?(var.options[:group]) } configured_variables.to_a.keep_if(&from_required_group) end def self.configured_variables configuration.attribute_set.dup#.to_a.keep_if(&var_from_required_group) end def self.provided_variable_names ENV.keys.map(&:to_sym) end def self.non_coercible_variables required_variables.reject(&method(:variable_coercible?)) end def self.variable_coercible?(variable) var_value = env_value_or_default(variable) return true if var_value.respond_to?(:call) variable.coerce var_value rescue Virtus::CoercionError return false end def self.missing_variable_names unprovided = required_variable_names - provided_variable_names unprovided -= names_of_required_variables_with_defaults if defaults_enabled? unprovided end def self.names_of_required_variables_with_defaults required_variables_with_defaults.map(&:name).map(&:to_sym) end def self.required_variables_with_defaults required_variables.map do |v| v unless v.default_value.value.nil? end.compact end def self.defaults_enabled? configuration.enable_defaults end def self.method_missing(method, *args, &block) respond_to_missing?(method) ? @instance.public_send(method, *args, &block) : super end def self.respond_to_missing?(method, include_private = false) @instance.respond_to?(method) || super end end