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.



77
78
79
# File 'lib/rexpro/message.rb', line 77

def type
  @type
end

Instance Method Details

#define_fields(hsh) ⇒ Object



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

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



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

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



88
89
90
# File 'lib/rexpro/message.rb', line 88

def field_methods
  @field_methods ||= {}
end

#fieldsObject



84
85
86
# File 'lib/rexpro/message.rb', line 84

def fields
  @fields ||= []
end