Skip to content

Working with Hashes

topofocus edited this page May 29, 2019 · 5 revisions

(under Construction)

Creation

> the_record =  TestModel.create ll: { tus: 6, tux: 9, zottel: 'rt'}
> the_record.to_human
  <TestModel: ll : {:tus=>6, :tux=>9, :zottel=>"rt"}>

Access

> the_record.ll[:tux]            # => 6
> the_record.ll.slice /tu/       # => {:tus=>6, :tux=>9} 

Assignment / Add

> the_record.ll[:zt] = 7
  INFO->update #25:0 set ll.zt = 7  return after @this
  <TestModel: ll : {:tus=>6, :tux=>9, :zottel=>"rt", :zt=>7}> 

Update

> the_record.ll[:zt] = 'uz'
  INFO->update #25:0 set ll.zt = 'uz'  return after @this
  <TestModel: ll : {:tus=>6, :tux=>9, :zottel=>"rt", :zt=>"uz"}>

Remove / Delete

> the_record.ll.remove :zottel
  INFO->update #25:0 remove ll.zottel   return after @this
  <TestModel: ll : {:tus=>6, :tux=>9, :zt=>"uz"}>

Clone this wiki locally