Module: Nexpose::TypedAccessor

Included in:
Alert
Defined in:
lib/nexpose/api.rb

Instance Method Summary collapse

Instance Method Details

#typed_accessor(name, type) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/nexpose/api.rb', line 87

def typed_accessor(name, type)

  # here we dynamically define accessor methods
  define_method(name) do
    instance_variable_get("@#{name}")
  end

  define_method("#{name}=") do |value|
    instance_variable_set("@#{name}", value)
  end

  define_method("#{name}_type") do
    type
  end
end