Class: Aliyun::Common::Struct::Base
- Inherits:
-
Object
- Object
- Aliyun::Common::Struct::Base
- Extended by:
- AttrHelper
- Defined in:
- lib/aliyun/common/struct.rb
Direct Known Subclasses
OSS::Bucket, OSS::BucketEncryption, OSS::BucketLogging, OSS::BucketReferer, OSS::BucketVersioning, OSS::BucketWebsite, OSS::CORSRule, OSS::Callback, OSS::Config, OSS::LifeCycleRule, OSS::Multipart::Part, OSS::Multipart::Transaction, OSS::Object, STS::Config, STS::Policy, STS::Token
Defined Under Namespace
Modules: AttrHelper
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Base
constructor
A new instance of Base.
- #to_s ⇒ Object
Methods included from AttrHelper
Constructor Details
#initialize(opts = {}) ⇒ Base
Returns a new instance of Base.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/aliyun/common/struct.rb', line 34 def initialize(opts = {}) extra_keys = opts.keys - attrs unless extra_keys.empty? fail Common::Exception, "Unexpected extra keys: #{extra_keys.join(', ')}" end attrs.each do |attr| instance_variable_set("@#{attr}", opts[attr]) end end |
Instance Method Details
#to_s ⇒ Object
46 47 48 49 50 51 |
# File 'lib/aliyun/common/struct.rb', line 46 def to_s attrs.map do |attr| v = instance_variable_get("@#{attr}") "#{attr.to_s}: #{v}" end.join(", ") end |