Class: Avrodrome::Schema

Inherits:
Object
  • Object
show all
Defined in:
lib/avrodrome/schema.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body:, id:, version:, name:) ⇒ Schema

Returns a new instance of Schema.



5
6
7
8
9
10
# File 'lib/avrodrome/schema.rb', line 5

def initialize(body:, id:, version:, name:)
  @body = body
  @id = id
  @version = version
  @name = name
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



3
4
5
# File 'lib/avrodrome/schema.rb', line 3

def body
  @body
end

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/avrodrome/schema.rb', line 3

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/avrodrome/schema.rb', line 3

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



3
4
5
# File 'lib/avrodrome/schema.rb', line 3

def version
  @version
end

Instance Method Details

#to_hashObject



12
13
14
15
16
17
18
19
# File 'lib/avrodrome/schema.rb', line 12

def to_hash
  {
    subject: name,
    version: version,
    id: id,
    schema: body.to_s
  }
end

#to_jsonObject



21
22
23
# File 'lib/avrodrome/schema.rb', line 21

def to_json
  to_hash.to_json
end