0.0
No commit activity in last 3 years
No release in over 3 years
Polyrex-objects automically builds objects from a Polyrex schema
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.8.0, ~> 0.8
 Project Readme

#Introducing the Polyrex-Objects gem

The Polyrex-Objects gem is intended to be used internally by Polyrex only however it can be executed in isolation for testing purposes. In the example below the Polyrex-Objects gem is used to create an object as specified by the schema and populated with data from a Polyrex record represented as a Rexle element.

require 'polyrex' 

objects = PolyrexObjects.new('entities/section[name]/entity[name,count]').to_h 
#=> {"Section"=>PolyrexObjects::Section, "Entity"=>PolyrexObjects::Entity}


s =<<S
<?polyrex schema="entities/entity[title,count]"?>
Beans 34
Juice 25
S

polyrex = Polyrex.new
polyrex.parse s

element = polyrex.element 'records/*'
entity = objects['Entity'].new element

entity.title
#=> "Beans" 

entity.count
#=> "34" 

Resources