Sha256: 6196ce78d61745bf55374fe808276c98cb612caeb73bd2d8e5d08b1762e5d633
Contents?: true
Size: 1.99 KB
Versions: 4
Compression:
Stored size: 1.99 KB
Contents
# An arbitrary time in the past Then = Time.new(2021,02,06,22,11,52,'Z') # Test entity One (basic Entity) TE_KEYS = %i{id uri time num bool} class TestEntity < Entity fields( :id, %i{show}, # visible string :uri, %i{show}, URIBox, # uri field :time, TimeBox, # time field :num, NumBox, # numeric field :bool, BoolBox, # bool field ) end def new_te return TestEntity.with( id: "123", uri: URI("http://example.com"), time: Then, num: 42, bool: false ) end # # Test Entity Two (Entity with array fields) # class TestEntity2 < Entity fields( :id, %i{show}, NumBox, :names, [StringBox], :dates, [TimeBox], ) end def new_te2 return TestEntity2.with( id: 42, names: ["Alice", "Bob", "Christa", "Daniel"], dates: [Then, Then+1, Then+2], ) end # # Test Entity Three (Entity with another Entity as field type) # class TestEntity3 < Entity fields( :thing, %i{show}, :nested, TestEntity2, ) end def new_te3 return TestEntity3.with( thing: "some text", nested: new_te2, ) end TE3_JSON_TXT = <<EOF { "thing": "some text", "nested": { "id": 42, "names": [ "Alice", "Bob", "Christa", "Daniel" ], "dates": [ "2021-02-06T22:11:52Z", "2021-02-06T22:11:53Z", "2021-02-06T22:11:54Z" ] } } EOF # # Test Entity with Array of Entities # class TestEntity_ArrayOfNested < Entity fields( :boring, %i{show}, NumBox, :na, [TestEntity3], ) end def new_te_aon te3 = new_te3 te3a = new_te3 te2a = new_te2 te2a.names = ["Emma", "Frank", "Georgia"] te3a.nested = te2a return TestEntity_ArrayOfNested.with( boring: 1, na: [te3, te3a], ) end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
shep-0.2.2 | spec/entity_common.rb |
shep-0.2.1.pre.alpha0 | spec/entity_common.rb |
shep-0.2.0.pre.alpha0 | spec/entity_common.rb |
shep-0.1.0.pre.alpha0 | spec/entity_common.rb |