Day 27 – Building Hashes Using Beestings

Wondering if I could build a Hash object using beestings I built this test

ruleset a60x522 {
  meta {
    name "hash-beesting-test"
    description <<
      hash-beesting-test
    >>
    author "Mike Grace"
    logging on
  }

  rule tester {
    select when pageview ".*"
    pre {

      phone = 23423423;
      name = "Mike Grace";
      year = 1999;
      month = "December";

      userData = {
        "#{phone}": {
          "name": "#{name}",
          "year": {
            "#{year}": {
              "month": {
                "#{month}": {
                  "awesome": "yes!"
                }
              }
            }
          }
        }
      };

    }
    {
      emit <|
        console.log(userData);
      |>;
    }
  }
}
  • 15-18 set variables for use in beestings in hash
  • 20-33 hash object
  • 21 setting key in hash with beesting value of ‘phone’
  • 38 print to the console what the hash object looks like

Console output after running app on example.com with bookmarklet

Note: Using the variables in place of putting them in a beesting also works.

Get the bookmarklet to try it out yourself!

Gratuitous day 27 Grace face

About these ads
This entry was posted in Kynetx. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s