Class: ModelAuditor::Normalizers::String
- Inherits:
-
Object
- Object
- ModelAuditor::Normalizers::String
- Defined in:
- lib/model_auditor/normalizers/string.rb
Constant Summary collapse
- DEFAULTS =
{ limit: 97 }.freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(value, options = {}) ⇒ String
constructor
A new instance of String.
- #normalize ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/model_auditor/normalizers/string.rb', line 6 def @options end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/model_auditor/normalizers/string.rb', line 6 def value @value end |
Instance Method Details
#normalize ⇒ Object
17 18 19 20 21 |
# File 'lib/model_auditor/normalizers/string.rb', line 17 def normalize return value unless valid? value.truncate(limit) end |
#valid? ⇒ Boolean
23 24 25 |
# File 'lib/model_auditor/normalizers/string.rb', line 23 def valid? value.present? && value.respond_to?(:truncate) end |