Sha256: f204315405cd74073d61a23a1844f5e7e8d3d34039ebae82841a3d1cfbaea937

Contents?: true

Size: 1.03 KB

Versions: 61

Compression:

Stored size: 1.03 KB

Contents

controller :controller do
  action :index do
    on_entry %{
      original_page = {
        _head: "head",
        _next: "next",
        _id: "id",
        _type: "hash",
        entries: {
          "id1": {_sig: "sig1"},
          "id2": {_sig: "sig2"},
        },
        _hash: "hash",
      };

      //Now we make a new copy
      page = CopyPage(original_page);
      var a = EntryMutable(page, "id1");
      var b = EntryMutable(page, "id2");

      a.hello = "world";
      b.hello = "world";

      //This is a violation of the vm, it will set the original but not copied
      //This is because the page.entries[1] actually refers to the original_page.entries[1]
      //the array of original_page.entries belongs to original_page, but the entries inside it
      //are references. When you call entrymutable, you are making a copy and replacing that
      //entry in the array so that page.entries[0] is actually owned by page and is no longer apart
      //of original_page
      original_page.entries["id1"].foo = "bar";
    }
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
flok-0.0.105 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.103 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.102 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.101 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.100 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.99 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.98 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.97 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.96 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.95 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.94 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.93 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.92 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.91 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.90 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.89 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.88 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.87 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.86 spec/kern/assets/vm/macros/entry_mutable_ch.rb
flok-0.0.85 spec/kern/assets/vm/macros/entry_mutable_ch.rb