Module: Sequel::Plugins::SplitValues::InstanceMethods
- Defined in:
- lib/sequel/plugins/split_values.rb
Instance Method Summary collapse
-
#[](k) ⇒ Object
If there isn’t an entry in the values hash, but there is a noncolumn_values hash, look in that hash for the value.
-
#remove_key!(key) ⇒ Object
Remove the key from noncolumn values if it is present there.
-
#split_noncolumn_values ⇒ Object
Check all entries in the values hash.
Instance Method Details
#[](k) ⇒ Object
If there isn’t an entry in the values hash, but there is a noncolumn_values hash, look in that hash for the value.
49 50 51 52 53 54 55 |
# File 'lib/sequel/plugins/split_values.rb', line 49 def [](k) if (res = super).nil? @noncolumn_values[k] if !@values.has_key?(k) && @noncolumn_values else res end end |
#remove_key!(key) ⇒ Object
Remove the key from noncolumn values if it is present there. If it is not present there, then use the default behavior of removing it from values.
59 60 61 62 63 64 65 |
# File 'lib/sequel/plugins/split_values.rb', line 59 def remove_key!(key) if @noncolumn_values && @noncolumn_values.key?(key) @noncolumn_values.delete(key) else super end end |
#split_noncolumn_values ⇒ Object
Check all entries in the values hash. If any of the keys are not columns, move the entry into the noncolumn_values hash.
69 70 71 72 73 74 75 76 77 |
# File 'lib/sequel/plugins/split_values.rb', line 69 def split_noncolumn_values cols = (@values.keys - columns) return self if cols.empty? nc = @noncolumn_values ||= {} vals = @values cols.each{|k| nc[k] = vals.delete(k)} self end |