Module: Mongoid::Document
- Defined in:
- lib/mongoid_adjust.rb
Instance Method Summary collapse
Instance Method Details
#adjust!(attrs = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/mongoid_adjust.rb', line 30 def adjust!(attrs = {}) (attrs || {}).each_pair do |key, value| next if !has_key? key # only add to properties already present! adjust_by_proc!(key, value) if value.kind_of?(Proc) adjust_by_symbol!(key, value) if value.kind_of?(Symbol) || value.kind_of?(String) adjust_by_number!(key, value) if value.kind_of?(Numeric) # only add integer values end self end |
#has_key?(key) ⇒ Boolean
26 27 28 |
# File 'lib/mongoid_adjust.rb', line 26 def has_key? key @attributes[key.to_s] || respond_to?("#{key}=") end |