Class: BudaApi::Models::BaseModel

Inherits:
Object
  • Object
show all
Defined in:
lib/buda_api/models.rb

Overview

Base model class with common functionality

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ BaseModel



11
12
13
14
# File 'lib/buda_api/models.rb', line 11

def initialize(data = {})
  @data = data.is_a?(Hash) ? data : {}
  @raw_data = @data.dup
end

Instance Method Details

#rawObject

Access to raw API response data



17
18
19
# File 'lib/buda_api/models.rb', line 17

def raw
  @raw_data
end

#to_hObject

Convert to hash



22
23
24
# File 'lib/buda_api/models.rb', line 22

def to_h
  @data
end

#to_json(*args) ⇒ Object

Convert to JSON



27
28
29
# File 'lib/buda_api/models.rb', line 27

def to_json(*args)
  @data.to_json(*args)
end