Class: Twitch::Object
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Twitch::Object
- Defined in:
- lib/twitch/object.rb
Direct Known Subclasses
AutomodSetting, AutomodStatus, Badge, BannedEvent, BannedUser, BlockedTerm, BlockedUser, Channel, ChannelEditor, CharityCampaign, ChatMessage, Chatter, Clip, CustomReward, CustomRewardRedemption, Emote, EventsubConduit, EventsubConduitShard, EventsubSubscription, FollowCount, FollowedUser, Game, Goal, HypeTrainEvent, Moderator, ModeratorEvent, Poll, Prediction, Raid, SearchResult, Stream, StreamKey, StreamMarker, StreamSchedule, Subscription, SubscriptionCount, Tag, UnbanRequest, User, UserAuthorization, UserColor, Video, Vip, Warning
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Object
constructor
A new instance of Object.
- #to_ostruct(obj) ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Object
5 6 7 |
# File 'lib/twitch/object.rb', line 5 def initialize(attributes) super to_ostruct(attributes) end |
Instance Method Details
#to_ostruct(obj) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/twitch/object.rb', line 9 def to_ostruct(obj) if obj.is_a?(Hash) OpenStruct.new(obj.map { |key, val| [ key, to_ostruct(val) ] }.to_h) elsif obj.is_a?(Array) obj.map { |o| to_ostruct(o) } else # Assumed to be a primitive value obj end end |