Class: PrizePicks::Api::Responses::User

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/prizepicks/api/responses/user.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ User

Returns a new instance of User.



6
7
8
# File 'lib/prizepicks/api/responses/user.rb', line 6

def initialize(attributes)
  super to_obstruct(attributes)
end

Instance Method Details

#to_obstruct(_attributes) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/prizepicks/api/responses/user.rb', line 10

def to_obstruct(_attributes)
  case obj
  when Hash
    OpenStruct.new(obj.transform_values { |val| to_obstruct(val) })
  when Array
    obj.map { |o| to_obstruct(o) }
  else
    obj
  end
end