Module: DataMapper::Trimmer
- Defined in:
- lib/dm-trimmer/trimmer.rb,
lib/dm-trimmer/version.rb
Constant Summary collapse
- VERSION =
"0.1.0".freeze
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/dm-trimmer/trimmer.rb', line 7 def self.included(base) base.class_eval do alias_method :set_without_trimmer!, :set! alias_method :set!, :set_with_trimmer! end end |
Instance Method Details
#set_with_trimmer!(name, value) ⇒ Object
14 15 16 17 18 |
# File 'lib/dm-trimmer/trimmer.rb', line 14 def set_with_trimmer!(name, value) value = value.strip if value.respond_to?(:strip) value = nil if value.respond_to?(:empty?) && value.empty? set_without_trimmer!(name, value) end |