class Gillbus::V2::Structs::Base
Attributes
raw_data[R]
Public Class Methods
field(name, type, from: name.to_s, default: nil, enrich_with: nil)
click to toggle source
# File lib/gillbus/v2/structs/base.rb, line 20 def self.field(name, type, from: name.to_s, default: nil, enrich_with: nil) attr_reader name @fields_settings ||= [] @fields_settings << { name: name, type: type, from: from, default: default, enrich_with: enrich_with, } end
from_raw_data(raw_data)
click to toggle source
# File lib/gillbus/v2/structs/base.rb, line 32 def self.from_raw_data(raw_data) fields = Parser.new.parse_fields(raw_data, @fields_settings) new(raw_data: raw_data, **fields) end
new(raw_data:, **fields)
click to toggle source
# File lib/gillbus/v2/structs/base.rb, line 13 def initialize(raw_data:, **fields) @raw_data = raw_data fields.each do |field_name, field_value| instance_variable_set(:"@#{field_name}", field_value) end end