Class: Netflix::JsonResource

Inherits:
Object
  • Object
show all
Defined in:
lib/netflix/json_resource.rb

Direct Known Subclasses

Disc, Queue, User

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(map) ⇒ JsonResource

Returns a new instance of JsonResource.



20
21
22
# File 'lib/netflix/json_resource.rb', line 20

def initialize(map)
  @map = map
end

Class Method Details

.define_getter(*symbols) ⇒ Object

def from_json(json)

map = JSON.parse(json)
new(map)

end



10
11
12
13
14
15
16
17
# File 'lib/netflix/json_resource.rb', line 10

def define_getter(*symbols)
  #symbols = [symbols].flatten
  symbols.each do |symbol|
    define_method symbol do
      @map[symbol.to_s]
    end
  end
end