Sha256: 2d5a262823afa4b2bf14784f4d24a7756944d735c80a37641f7a29554629d05a
Contents?: true
Size: 939 Bytes
Versions: 2
Compression:
Stored size: 939 Bytes
Contents
module OpenActive module Concerns module JsonLdSerializable def self.included(base) base.extend(ClassMethods) end module ClassMethods def properties @properties ||= begin if superclass.respond_to?(:properties) superclass.properties.clone else {} end end end def property(field, as:) properties[as] = { field: field, } end end def values data = {} self.class.properties.each do |key, field| field_value = field[:field] data[key] = send(field_value) end data end def to_h data = {} self.class.properties.each do |_key, field| field_value = field[:field] data[field_value] = send(field_value) end data end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
openactive-0.5.0 | lib/openactive/concerns/json_ld_serializable.rb |
openactive-0.4.0 | lib/openactive/concerns/json_ld_serializable.rb |