module StructToIGLU

Constants

IGLU_SCHEMA_URI

Public Instance Methods

schema(company ='uk.co.simplybusiness', version = '1-0-0') click to toggle source
# File lib/ext/struct.rb, line 23
def schema(company ='uk.co.simplybusiness', version = '1-0-0')
  format(IGLU_SCHEMA_URI,
    company: company,
    version: version,
    # this assumes `type` is a (namespaced) Ruby class name
    # 'Idiophone::Events::JoinRequested' > 'join_requested'
    event: self.type.split('::').last.underscore,
  )
end
to_iglu() click to toggle source
# File lib/ext/struct.rb, line 33
def to_iglu
  {
    schema: self.schema,
    data:   self.to_h,
  }
end