Awesome, I love messing with Ruby and semantic web stuff. Thanks for posting this. Could you explain more? How do you implement the strongly-typed feature? How does it interoperate with the Ruby-RDF library? https://github.com/ruby-rdf
This DRY's up my code - I just encode the right way of forming JSON-LD and the correct objects and attributes in one place, the library. (That JSON-LD is from my live site, https://texas.public.law)
Details:
First I created a small library which wraps Rails ActiveModel Validations so they can be used in any Ruby object. And I supply a new validator, TypeValidator.
I'm not using Ruby-RDF at all. I looked into the current Ruby meta-data and strong typing work, and found it all too complex for my simpler use case:
I'm creating websites, and I want to embed correct JSON-LD-formatted schema.org in a rock-solid way: (1) Correct syntax, and (2) correct semantics. I've got the information as Rails models and objects, and I need to convert this to HTML/JSON-LD.
So all of these objects, like Organization above, recursively creates proper markup in response to #to_s:
<%= @an_organization %>
...instantiated from that class above, will result in this in the generated HTML page: