Class: Yandex360::Object
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Yandex360::Object
- Defined in:
- lib/yandex360/object.rb
Direct Known Subclasses
Alias, AllowList, AuditEvent, DeletedDepartment, DeletedDepartmentAlias, DeletedGroup, DeletedUser, Department, DepartmentAlias, DepartmentList, DnsRecord, Domain, Group, GroupList, Organization, User, UserAlias, UserList
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Object
constructor
A new instance of Object.
-
#to_ostruct(obj) ⇒ Object
Convert Array or Hash to OpenStruct.
Constructor Details
#initialize(attributes) ⇒ Object
Returns a new instance of Object.
7 8 9 |
# File 'lib/yandex360/object.rb', line 7 def initialize(attributes) super to_ostruct(attributes) end |
Instance Method Details
#to_ostruct(obj) ⇒ Object
Convert Array or Hash to OpenStruct
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/yandex360/object.rb', line 12 def to_ostruct(obj) case obj when Hash return OpenStruct.new if obj.empty? OpenStruct.new(obj.transform_values {|val| to_ostruct(val) }) when Array obj.map {|o| to_ostruct(o) } when nil nil else obj end end |