Class: Api::BaseApi
- Inherits:
-
Object
- Object
- Api::BaseApi
- Defined in:
- app/models/api/base_api.rb
Constant Summary collapse
- API_VERSION_REGEX =
/v[0-9]+(_[0-9]+)*/i
Instance Attribute Summary collapse
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(version = nil) ⇒ BaseApi
constructor
A new instance of BaseApi.
- #render(data) ⇒ Object
- #timestamps(json, data) ⇒ Object
Constructor Details
#initialize(version = nil) ⇒ BaseApi
Returns a new instance of BaseApi.
8 9 10 |
# File 'app/models/api/base_api.rb', line 8 def initialize(version=nil) set_api_version(version) end |
Instance Attribute Details
#api_version ⇒ Object
Returns the value of attribute api_version.
3 4 5 |
# File 'app/models/api/base_api.rb', line 3 def api_version @api_version end |
#params ⇒ Object
Returns the value of attribute params.
4 5 6 |
# File 'app/models/api/base_api.rb', line 4 def params @params end |
Instance Method Details
#render(data) ⇒ Object
12 13 14 |
# File 'app/models/api/base_api.rb', line 12 def render(data) respond_to?(api_version) ? self.send(api_version, data) : nil end |
#timestamps(json, data) ⇒ Object
16 17 18 19 20 |
# File 'app/models/api/base_api.rb', line 16 def (json, data) json.id data.id.to_s json.created_at data.created_at json.updated_at data.updated_at end |