Class: Netflix::JsonResource
- Inherits:
-
Object
- Object
- Netflix::JsonResource
- Defined in:
- lib/netflix/json_resource.rb
Class Method Summary collapse
-
.define_getter(*symbols) ⇒ Object
def from_json(json) map = JSON.parse(json) new(map) end.
Instance Method Summary collapse
-
#initialize(map) ⇒ JsonResource
constructor
A new instance of JsonResource.
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 |