«
Items support accessing metadata from different files
type | name |
---|---|
Switch | TestSwitch |
TestSwitch.meta['animalsounds'] = { 'land' => { 'cow' => 'moo'}}
logger.info("Metadata animalsounds created for TestSwitch: #{TestSwitch.meta['animalsounds']}")
TestSwitch.meta['animalsounds'] = {"land"=>{"cow"=>"moo"}}
code = '<metadata>'
logger.info("#{code}: #{<metadata>}")
metadata | value | |
---|---|---|
TestSwitch.meta["animalsounds"] | {"land"=>{"cow"=>"moo"}} | |
TestSwitch.meta.dig("animalsounds", "land") | {"cow"=>"moo"} | |
TestSwitch.meta.dig("animalsounds", "land", "cow") | moo |
code = '<metadata>'
logger.info("#{code}: #{<metadata>}")
metadata | value | |
---|---|---|
TestSwitch.meta["animalsounds"] | {"land"=>{"cow"=>"moo"}} | |
TestSwitch.meta.dig("animalsounds", "land") | {"cow"=>"moo"} | |
TestSwitch.meta.dig("animalsounds", "land", "cow") | moo |
TestSwitch.meta['animalsounds'] = {"land"=>{"cow"=>"moo"}}
logger.info("Metadata checks out") if <metadata> == <value>
metadata | value | |
---|---|---|
TestSwitch.meta["animalsounds"] | {"land"=>{"cow"=>"moo"}} | |
TestSwitch.meta.dig("animalsounds", "land") | {"cow"=>"moo"} | |
TestSwitch.meta.dig("animalsounds", "land", "cow") | "moo" |
logger.info("Metadata checks out") if <metadata> == <value>
metadata | value | |
---|---|---|
TestSwitch.meta["animalsounds"] | {"land"=>{"cow"=>"moo"}} | |
TestSwitch.meta.dig("animalsounds", "land") | {"cow"=>"moo"} | |
TestSwitch.meta.dig("animalsounds", "land", "cow") | "moo" |
TestSwitch.meta['animalsounds'] = { 'land' => <value> }
require 'json'
logger.info("Metadata to_json: #{TestSwitch.meta.dig("animalsounds", "land").to_json}")
value | json | |
---|---|---|
{'cow'=>'moo'} | {"cow":"moo"} | |
[{'cow'=>'moo'},{'sheep'=>'baa'}] | [{"cow":"moo"},{"sheep":"baa"}] |