lib/clamp/attribute/instance.rb in clamp-1.2.0 vs lib/clamp/attribute/instance.rb in clamp-1.2.1
- old
+ new
@@ -58,20 +58,40 @@
else
command.send(attribute.write_method, value)
end
end
+ def signal_usage_error(*args)
+ command.send(:signal_usage_error, *args)
+ end
+
def default_from_environment
return if self.defined?
return if attribute.environment_variable.nil?
return unless ENV.key?(attribute.environment_variable)
# Set the parameter value if it's environment variable is present
value = ENV[attribute.environment_variable]
begin
take(value)
rescue ArgumentError => e
- command.send(:signal_usage_error, Clamp.message(:env_argument_error, :env => attribute.environment_variable, :message => e.message))
+ signal_usage_error Clamp.message(:env_argument_error, :env => attribute.environment_variable, :message => e.message)
end
+ end
+
+ def unset?
+ if attribute.multivalued?
+ read.empty?
+ else
+ read.nil?
+ end
+ end
+
+ def missing?
+ attribute.required? && unset?
+ end
+
+ def verify_not_missing
+ signal_usage_error attribute.option_missing_message if missing?
end
end
end