Class: BaseDTO
- Inherits:
-
Object
- Object
- BaseDTO
- Defined in:
- lib/models/base_dto.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #from_json(json) ⇒ Object
-
#initialize(json) ⇒ BaseDTO
constructor
A new instance of BaseDTO.
Constructor Details
#initialize(json) ⇒ BaseDTO
Returns a new instance of BaseDTO.
6 7 8 |
# File 'lib/models/base_dto.rb', line 6 def initialize(json) from_json(json) end |
Class Method Details
.from_json(json) ⇒ Object
2 3 4 |
# File 'lib/models/base_dto.rb', line 2 def self.from_json(json) new(json) end |
Instance Method Details
#from_json(json) ⇒ Object
10 11 12 13 |
# File 'lib/models/base_dto.rb', line 10 def from_json(json) data = json.is_a?(String) ? JSON.parse(json) : json data.each { |key, value| instance_variable_set("@#{key}", value) } end |