Module: Rexpro::Message::Base::ClassMethods

Defined in:
lib/rexpro/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#typeObject

Returns the value of attribute type.



79
80
81
# File 'lib/rexpro/message.rb', line 79

def type
  @type
end

Instance Method Details

#define_fields(hsh) ⇒ Object



94
95
96
97
98
99
100
# File 'lib/rexpro/message.rb', line 94

def define_fields(hsh)
  hsh.each do |name, method|
    fields << name
    field_methods[name] = method
    attr_accessor(name)
  end
end

#define_meta_fields(*names) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
# File 'lib/rexpro/message.rb', line 102

def define_meta_fields(*names)
  names.each do |name|
    # RexPro uses mixedCase keys in meta
    name_parts = name.to_s.split('_')
    name_parts[1..-1].each(&:capitalize!)
    rexpro_name = name_parts.join

    define_method(name) { meta[rexpro_name] }
    define_method("#{name}=") { |value| meta[rexpro_name] = value }
  end
end

#field_methodsObject



90
91
92
# File 'lib/rexpro/message.rb', line 90

def field_methods
  @field_methods ||= {}
end

#fieldsObject



86
87
88
# File 'lib/rexpro/message.rb', line 86

def fields
  @fields ||= []
end