Module: String::NoBrainerExtensions
- Included in:
- String
- Defined in:
- lib/no_brainer/document/types/string.rb
Constant Summary collapse
- InvalidType =
NoBrainer::Error::InvalidType
Instance Method Summary collapse
Instance Method Details
#nobrainer_cast_user_to_model(value) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/no_brainer/document/types/string.rb', line 5 def nobrainer_cast_user_to_model(value) case value when String then value when Symbol then value.to_s else raise InvalidType end.tap do |str| max_length = NoBrainer::Config.max_string_length raise InvalidType.new(:error => { :message => :too_long, :count => max_length }) if str.size > max_length end end |