class OrientSupport::Hash
Public Class Methods
new(modelinstance, args) { |: attributes.key(self)| ... }
click to toggle source
Calls superclass method
# File lib/support/orient.rb, line 221 def initialize modelinstance, args super() @orient = modelinstance self.merge! args @name = block_given? ? yield : modelinstance.attributes.key(self) self end
Public Instance Methods
[](arg)
click to toggle source
Calls superclass method
# File lib/support/orient.rb, line 285 def [] arg super end
delete_if(&b)
click to toggle source
Calls superclass method
# File lib/support/orient.rb, line 269 def delete_if &b super &b @orient.update set:{ @name => self} end
merge(**arg)
click to toggle source
Inserts the provided Hash
to the (possibly empty) list-property and updates the dataset
Keys are translated to symbols
Calls superclass method
# File lib/support/orient.rb, line 241 def merge **arg @orient.update @name => super(**arg) @orient.reload! end
Also aliased as: <<
remove(*k)
click to toggle source
removes a key-value entry from the hash.
parameter: list of key's
returns the modified OrientSupport::Hash
ie, given
b => <Base[51:0]: < Base: 51:0 >, a_set : {:warrant_value=>["8789", "HKD"], :what_if_pm_enabled=>["true", ""], :t_bill_value=>["0", "HKD"]}>
c= b.a_set.remove :warrant_value INFO->update #51:0 remove a_set = 'warrant_value' return after $current c => {:what_if_pm_enabled=>[“true”, “”], :t_bill_value=>[“0”, “HKD”]}
# File lib/support/orient.rb, line 261 def remove *k # todo combine queries in a transaction r= k.map{|key| @orient.update{ "remove #{@name} = #{key.to_s.to_or} " } } @orient.reload!.send @name end
slice(arg)
click to toggle source
slice returns a subset of the hash
excepts a regular expression as well
Calls superclass method
# File lib/support/orient.rb, line 278 def slice arg if arg.is_a? Regexp find_all{ |key| key.to_s.match(arg) }.to_h else super arg.to_sym end end
store(k, v)
click to toggle source
# File lib/support/orient.rb, line 229 def store k, v @orient.update { "set #{@name}[#{k.to_s.to_or}] = #{v.to_or} "}[@name] #if check_if_complete @orient.reload! end
Also aliased as: []=