lib/koine/attributes/adapter/base.rb in koine-attributes-1.1.0 vs lib/koine/attributes/adapter/base.rb in koine-attributes-1.2.0
- old
+ new
@@ -3,11 +3,11 @@
module Adapter
class Base
attr_accessor :attribute_name
def initialize
- @attribute_name = 'AnonymousAttribute'
+ @attribute_name = 'annonymous_attribute_name'
end
def coerce(value)
return coerce_nil if value.nil?
@@ -38,11 +38,11 @@
def coerce_nil
if @nil_value_set
return @nil_value.respond_to?(:call) ? @nil_value.call : @nil_value
end
- raise ArgumentError, 'Cannot be nil', attribute_name
+ raise_error('Cannot be nil')
end
def coerce_not_nil(_value)
raise NotImplementedError
end
@@ -59,10 +59,14 @@
end
def wrap_errors
yield
rescue StandardError => error
- raise Koine::Attributes::ArgumentError.new(error, attribute_name)
+ raise_error(error)
+ end
+
+ def raise_error(message)
+ raise Koine::Attributes::InvalidAttributeError.new(message, attribute_name)
end
end
end
end
end