Hello, first of all, good stuff with this gem! Very useful making global app settings dynamic, but also to quickly create a single variable to "remember" something. Props to all the contributors and maintainer!
So I might be wrong, because I just started using this gem, but it seems that the type set for a field is being cast:
What do you think about making it so that if the type is set and a different type is given, an error is thrown?
# field :foo, type: :integer
Setting.foo = 'hello' # InvalidTypeError - Got type String, expected type Integer
# field :bar, type :date_time
Setting.bar = '2020-12-30' # InvalidTypeErrror - Got type String, expected type DateTime
Personally, I feel like this will make it more robust to use because:
Validate is only required for more complex validations.
It prevents giving a setting an incorrect value.
It makes calling a setting more reliable and you know it will return the expected type.
Like I said, I just started using the gem, so I might be overlooking something obvious.
Hello, first of all, good stuff with this gem! Very useful making global app settings dynamic, but also to quickly create a single variable to "remember" something. Props to all the contributors and maintainer!
So I might be wrong, because I just started using this gem, but it seems that the
type
set for afield
is being cast:What do you think about making it so that if the type is set and a different type is given, an error is thrown?
Personally, I feel like this will make it more robust to use because:
Like I said, I just started using the gem, so I might be overlooking something obvious.
WDYT? Could this be a feature for v3? :)