Class: Aliyun::Log::Common::AttrStruct

Inherits:
Object
  • Object
show all
Extended by:
AttrHelper
Defined in:
lib/aliyun/log/common/attr_struct.rb

Direct Known Subclasses

Aliyun::Log::Config, Logstore, Project

Defined Under Namespace

Modules: AttrHelper

Instance Method Summary collapse

Methods included from AttrHelper

attrs

Constructor Details

#initialize(opts = {}) ⇒ AttrStruct

Returns a new instance of AttrStruct.



16
17
18
19
20
21
22
23
# File 'lib/aliyun/log/common/attr_struct.rb', line 16

def initialize(opts = {})
  extra_keys = opts.keys - attrs
  raise "Unexpected extra keys: #{extra_keys.join(', ')}" unless extra_keys.empty?

  attrs.each do |attr|
    instance_variable_set("@#{attr}", opts[attr])
  end
end

Instance Method Details

#to_sObject



25
26
27
28
29
30
# File 'lib/aliyun/log/common/attr_struct.rb', line 25

def to_s
  attrs.map do |attr|
    v = instance_variable_get("@#{attr}")
    "#{attr}: #{v}"
  end.join(', ')
end